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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Month(date) and Year(date)

Status
Not open for further replies.

Collin79

Programmer
Dec 31, 2000
31
0
0
MX
Hi!

I need the Month and Year of the date system, I'm using Month(date) and Year(date) function and it works ok, but in month I need two digits (february=02 not 2) and in year I need two digits too (01 not 2001)

I've tried with Format() but I can't do that, any hint?

Thanks

Collin79
 
Try this:
Code:
Dim sMonth As String
Dim sYear As String
    
sMonth = Format(Now, "mm")
sYear = Format(Now, "yy")
    
MsgBox "Month: " & sMonth & vbCrLf & _
       "Year: " & sYear
 
Here's all you need. Format(Now,"MM YY")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top