What happened to the Date() function?

  • Thread starter Thread starter Christian Blackburn
  • Start date 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
 
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.
 
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.
 
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
 
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")
 
Back
Top