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

date wrong format

Status
Not open for further replies.

derwent

Programmer
May 5, 2004
428
GB
on my machine when I use

FormatDateTime(date(),vbshortdate)

I get 11/18/2004, however on another machine I get 18/11/2004 (correct format).

I have looked in iis but cannot find a date setting and also in control panel > regional options but that says it is in the correct format dd/mm/yyyy.

any ideas folks?
 
What are you doing with this date ?
Is it displayed in a text box, a report, exported to word , excel ?

(If you are sure you want always the format dd/mm/yyyy - regardless of the user's setting, instead of vbshortdate, use "dd/mm/yyyy".
 
I tend to use 'Format(Date, "dd/mm/yyyy")' or if you prefer the American 'Format(Date, "mm/dd/yyyy")

I don't think this is affected by the machines regional settings.

[gray]Experience is something you don't get until just after you need it.[/gray]
 
hi cbsm

I am using it on a webpage to enter todays date into SQL Server, then grab it back out when I display the results on a page. I want to eventually be able to select results by month.

I tried changing vbshortdate to dd/mm/yyyy

FormatDateTime(date(),dd/mm/yyyy)

but it produced an error

thanks
 
Check out faq222-2244, which gives some guidance on basic research and help availability, as VBHelp has good coverage of these basic functions.

FormatDateTime is a simplified version of Format, which only takes a numeric argument. If you want to use the Format function (as bigalbigal suggests above) you will need the quote marks round dd/mm/yyyy per his example.


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
If, as it seems, you are using VBScript in an ASP web page try calling the SetLocale("EN-GB") function before calling FormatDateTime. This will set the default date format to dd/mm/yyyy.

To return to US style dates use SetLocale("EN-US")

SetLocale and GetLocale were introduced in VBScript 5.0


Bob Boffin
 
If indeed you are using VBScript (which is different in many respects from VB) you may not have discovered forum329 which is specific to VBScript. If it's ASP you're after, try forum333. Otherwise check out the Browse Forums link in the top left panel just under your name

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top