Using the Date() function

  • Thread starter Thread starter Patrick McGuire
  • Start date Start date
P

Patrick McGuire

I need to get the current date in vb .NET. In vba I
always used the Date() function, and the help in .NET
indicates that this function still exists, but I can't
seem to find it. The Now() function works just fine, but
when I try to use Date(), I get an error. Am I missing a
reference? What is it?

Thanks,

Pat
 
If you just need the date portion without the time, try:

Date.Now.Date()

Date.Now() returns the current Time and Date. .Date returns the Date portion
of the date instance only.

HTH,

Trev.
 
Codemonkey said:
If you just need the date portion without the time, try:

Date.Now.Date()

Date.Now() returns the current Time and Date. .Date returns the Date
portion of the date instance only.

Right. Shorter: Date.Today :-)
 
lol. I've used that before too. Call it FBFS ("Friday Brain Fried Syndrome")
on my part. ;)
 
* "Patrick McGuire said:
I need to get the current date in vb .NET. In vba I
always used the Date() function, and the help in .NET
indicates that this function still exists, but I can't
seem to find it. The Now() function works just fine, but
when I try to use Date(), I get an error. Am I missing a
reference? What is it?

Why not use 'DateTime.Now'?
 
Back
Top