Current Date

  • Thread starter Thread starter Guest
  • Start date Start 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.
 
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?
 
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
 
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)
 
Back
Top