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

Date question

Status
Not open for further replies.
Mar 19, 2003
57
US
What function can I use to get the month and year from a date.

The regional setting in windows for date is short date (08/13/2004). I used month(Date) hoping to get "08", but I get "8". Also, when I use Year(Date), i'de like to get "04", instead of "2004."

Can anyone help
 
You will have to work at it a bit. use year(), Month(), cstr(), mid() to get what you want.
 
Easiest way to do this is with format. It returns text if you use it like this:

format (Date(), "MM") (Returns 08)
format (Date(), "YY") (Returns 04)
format (Date(), "YYYY") (Returns 2004)

Dd for day. You can mix and match to your needs.

ChaZ





"When religion and politics ride in the same cart...the whirlwind follows."
Frank Herbert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top