Prefix the Month(Now) function with a Zero?

P

Paul D. Fox

OK, its a lame question... I think my mind is getting fried today. The
Month(Now) function returns a "1" if its Janurary and I'd like it to be a
"01". Can anyone help me with this one?

P
 
J

John

Paul D. Fox said:
OK, its a lame question... I think my mind is getting fried today. The
Month(Now) function returns a "1" if its Janurary and I'd like it to be a
"01". Can anyone help me with this one?

Very lame ... but here you are:

Right("00" & Month(Now), 2)

Good luck,
John
 
M

Mythran

John said:
Very lame ... but here you are:

Right("00" & Month(Now), 2)

Good luck,
John

Without using VisualBasic namespace would be:

Dim s As String = "00" & DateTime.Now.Month
s = s.SubString(s.Length - 2)


Not as brief...but oh well :) I tend to not like using the VisualBasic
namespace (even though it is there and probably won't go away...other than
that, for no other reasons heh).

Mythran
 
V

vMike

Paul D. Fox said:
OK, its a lame question... I think my mind is getting fried today. The
Month(Now) function returns a "1" if its Janurary and I'd like it to be a
"01". Can anyone help me with this one?

P
How about DateTime.Now.tostring("MM")
Mike
 
A

Alan Silver

OK, its a lame question... I think my mind is getting fried today. The
Month(Now) function returns a "1" if its Janurary and I'd like it to be a
"01". Can anyone help me with this one?

I know several other answers have been posted, but I thought I'd add
another, just to show there's yet another way to do the same!!

(Month(Now)<10?"0":"") + Month(Now)
 

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top