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

FormatDateTime

Status
Not open for further replies.

AndyApp

Programmer
Dec 20, 2001
259
GB
People urgent problem,

When i use the "formatdatetime(date, 2)" instead of getting what every website on earth says i'll get "dd/mm/yyyy" i just get "dd/mm/yy". and if I use "formatdatetime(date,1)" instead of "monday, january 02, 2002" i just get "02 December 02"?

Can anyone tell me what's going on? "Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway" - Jim Davis (Garfield)
 
FormatDate with the name arg. of 2 outputs only the 02 for the year. in order for you to get the full 2002 you need to do a little formatting.
take a look at this FAQ faq329-2091
it should help you in getting what you want My most satisfying and best work has come from helping others

admin@onpntwebdesigns.com
 
after reading the FAQ I didn't make it very well detailed on what is going on there in reference to name of the month, year, or day. So I'm going to edit it to state that but for this try
DateToday = Month(date()) & "/" & Day(Date()) & "/" & Year(Date())

Month Day and Year will return the numeric value, and thus the
MonthName etc. returns the proper name.
My most satisfying and best work has come from helping others

admin@onpntwebdesigns.com
 
I think spazman nailed it.
Code:
Constant    Value  Description
vbShortDate   2    Display a date using the short date format
                   specified in your computer's regional settings.
Right out of the docs. Not sure where you got the idea you were guaranteed dd/mm/yyyy, perhaps just some examples that seemed consistent?

I recommend using the built-in named constants wherever they're available. Coding by "magic numbers" is considered bad form. This way somebody maintaining your code will have an idea what you were intending when you wrote it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top