Reputation: 31
in a datepicker i use DateValue(Now) to get the current date . it gives date-month-year
but i require to store only the month value from the same datepicker. wht shoud i do ?
Upvotes: 0
Views: 4533
Reputation: 30398
To get the month as a string use Format as Richard suggests
MsgBox "Month name is " & Format$(yourDateValue, "mmm")
To get the month number use DatePart
MsgBox "Month number is " & DatePart("m", yourDateValue)
Upvotes: 2
Reputation: 3012
The month can be extracted from the date using the Format$ function:
Print "Month is ";Format$(yourDateValue,"mm")
See this page for all the possibilities.
Upvotes: 3