Current Date

G

Guest

I am working on a project for an XDA II. I am using VB.NET 2003 and am
having issues getting the current date.

My code is:-
Format(Now, "d/m/yyyy")

The output is 04/58/2006. Am I doing something wrong, or is there a better
way to get the current date into the format above?

Much appreciated.
 
G

Guest

Chris,

Thanks for your reply. That code works great the formatting, however I also
append the date to the file that gets created, and so I don't want '/' in the
file name.

Any ideas?
 
P

Peter Foot [MVP]

You can use Now.ToString("d-M-yyyy") for example to use an alternative
separator in your format string. Note the error in your first example -
lowercase m returns the minutes portion of the date, uppercase M returns the
month.

Peter
 
G

Gilles Kohl [MVP]

I am working on a project for an XDA II. I am using VB.NET 2003 and am
having issues getting the current date.

My code is:-
Format(Now, "d/m/yyyy")

The output is 04/58/2006. Am I doing something wrong, or is there a better
way to get the current date into the format above?

Could the problem be that the lowercase "m" displays the minute, while
you probably want the month?

(See http://msdn2.microsoft.com/en-us/library/73ctwf33.aspx)

Try e.g. Format(Now, "dd_MM_yyyy")

(If you append to the filename, you may want to use "yyyy_MM_dd"
instead for better "sortability")

Regards,
Gilles [MVP].

(Please reply to the group, not via email)
 

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