What happened to the Date() function?

  • Thread starter Christian Blackburn
  • Start date
C

Christian Blackburn

Hi Gang,
VB6 has a command called Date and it would not to surprisingly return the
date in the following ways:

Date() = 9/10/2003

Date(now) = 9/10/2003

Date("8/12/2000 12:20PM") = 8/12/2000

What is the equivalent of this command in VB.Net?

Thanks in Advance,
Christian Blackburn
 
A

Armin Zingler

Christian Blackburn said:
VB6 has a command called Date and it would not to surprisingly return
the date in the following ways:

Date() = 9/10/2003

Date(now) = 9/10/2003

Date("8/12/2000 12:20PM") = 8/12/2000

This code does not work in my version of VB6. Is this really VB6 code? Date
is only a property of the VBA.DateTime module. You can also set the date
using

Date = #8/12/2000#

but the syntax

Date(now) = ...

is not valid.
 
H

Herfried K. Wagner [MVP]

Hello,

Christian Blackburn said:
VB6 has a command called Date and it would not to
surprisingly return the date in the following ways:

Date() = 9/10/2003

Date(now) = 9/10/2003

Date("8/12/2000 12:20PM") = 8/12/2000

What is the equivalent of this command in VB.Net?

I am not sure which VB Classic function you are referring to. There is no
parameterized 'Date' function in VB Classic. Do you refer to 'DateValue'?

Maybe you want to instantiate 'DateTime' from a string containing the date
information. You can use 'DateTime.Parse' for this purpose.
 
C

Christian Blackburn

Hi Guys,
Thanks again for the help I would up going with the following syntax:
strFile_Date = DateTime.Today & " at " & DateTime.Now.Hour & ":" &
DateTime.Now.Minute

Cheers,
Christian
 
C

Chris Dunaway

Thanks again for the help I would up going with the following syntax:
strFile_Date = DateTime.Today & " at " & DateTime.Now.Hour & ":" &
DateTime.Now.Minute

Just for your information, you can shorten that to the following:

strFile_Date = Date.Now.ToString("MM/dd/yyyy a\t h:mm tt")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top