biplob
biplob

Reputation: 31

How to get selected day/month and year from vb datepicker

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

Answers (2)

MarkJ
MarkJ

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

Richard Brightwell
Richard Brightwell

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

Related Questions