Prefix the Month(Now) function with a Zero?

  • Thread starter Thread starter Paul D. Fox
  • Start date Start date
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
 
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
 
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
 
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
 
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)
 
Back
Top