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

VBScript date handling is aching my brain, please help me!

Status
Not open for further replies.

AlanC5

Programmer
Jun 3, 2001
1
GB
Everything was going great - I had a plan. Whenever I used any dates in my ASP app I made sure they went into the Access database in mid format: 12-Jun-2001 12:03:00.

I thought this would solve the international date format problems that would crop up, but oh no. I've created all of the back end and that works fine, but now I come to get dates back out of Access it's giving me them in the usual cryptic style of 03/06/2001 - is it the 3rd of June or the 6th of May? From my applications point of view, I just don't know..and as this is for a group calendar, it's "fairly" important to get this right!

My question then (sorry for the waffle but this is really stumping me and I like to write things out when my brain aches)

>> &quot;Is there a sure fire way to always get a date out of Access in a format you know will be consistent around the world?&quot; <<

Oh, dates are such a pain. It's taken me nearly a week just to write the validation and event creation stuff, and now I'm doing the display of the calendar this happens! Please help me...puh-lease!

 
I'm not sure what your problem is. Are you relying on the default date formatting you get if a variant has a date serial in it?

I did several tests and don't have a problem. Using a test.vbs file like this one:
Code:
Dim theDate
theDate = #January 9, 1979 1:5:9 PM#
MsgBox FormatDateTime(theDate, vbShortDate) _
       & &quot; &quot; & FormatDateTime(theDate, vbLongDate) _
       & &quot; &quot; & FormatDateTime(theDate, vbGeneralDate)
I proceeded to set different formats for short date and long date and time via Control Panel Regional Settings.

Using the formats dd-MMM-yyyy and HH:mm:ss gives me just what you say you put into the database when I use
Code:
vbGeneralDate
as the NamedFormat (second parameter to FormatDateTime).

Don't forget that this is all server side so the client's settings have nothing to do with it... or are you using some kind of client-side data-bound control?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top