469,923 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

Using the Date() function

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
Nov 20 '05 #1
4 1789
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.
"Patrick McGuire" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...
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

Nov 20 '05 #2
"Codemonkey" <hu*********@hotmail.com> schrieb
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 :-)
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
lol. I've used that before too. Call it FBFS ("Friday Brain Fried Syndrome")
on my part. ;)

"Armin Zingler" <az*******@freenet.de> wrote in message
news:eK**************@TK2MSFTNGP11.phx.gbl...
"Codemonkey" <hu*********@hotmail.com> schrieb
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 :-)
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
* "Patrick McGuire" <an*******@discussions.microsoft.com> scripsit:
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'?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Japhy | last post: by
4 posts views Thread by C White | last post: by
16 posts views Thread by John Hanley | last post: by
6 posts views Thread by BOMEz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.