format a number (eg month) to get leading zeros

D

Doug

I need to return 2 digits of month
eg for myDate = "2003/09/07 07:09" I want to return month as 09
this code = FormatNumber(Month(myDate), 0, vbTrue
doesn't work for me
Thanks
 
T

Tim Ferguson

FormatNumber(Month(myDate), 0, vbTrue)
doesn't work for me.

Format(Month(myDate), "00")

the reference to FormatNumber suggests you may be working in ASP or VBS, in
which case you have to cook nearly all your formats yourself:

Right("00" & FormatNumber(Month(myDate), 0, vbTrue), 2)

which reminds everybody what a crappy, half-finished language it really is.
Oh, sorry Matron, coming now....


B Wishes


Tim F
 

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