Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formating current date

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I am trying to format the current date to a format like "mm/dd/yyyy" I am using the following code

thedate.text = setdate.ToString("mm/dd/yyyy")

this is the result it is giving me. 00/02/2003. Why the 00???

Any help would be great.

Scott
 
Scott,

In your date format string, you use lowercase m's, which correspond to minutes. Try uppercase M's for the month:

thedate.text = setdate.ToString("MM/dd/yyyy")

(I have to admit it tripped me up the first time I used it too!)

HTH
Kevin B.
.Net Programmer [thumbsup]
 
Thanks Kevin. I knew it was something simple!!

sCOTT
 
If you are using the date type then you can also use.

datevar.toshortdatestring

The date type also has a few other built in formats That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top