Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: RE: Here's a good one - Date/Time issues.


Message #1 by "Ken Schaefer" <ken@a...> on Thu, 18 Jul 2002 11:29:35 +1000
It depends on:
a) the system settings for that user
www.adopenstatic.com/faq/systemdateformat.asp

b) whatever LCID you set for the page in question (you can override the
system settings on a per-page basis by setting an appropariate CodePage, or
Session.LCID)
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q229690

So, if your settings are for British English then: 10/5/2002 is 10th May
2002, but if your settings are for US English, then 10/5/2002 is 5th October
2002.

So in dealing with Access you need:
a) so set your LCID appropriately on each page (so that the VBScript
formatting functions work properly)
b) always send the dates to Access as yyyy/mm/dd [hh:mm:ss AM/PM] (if you
need the time as well). This is ISO format, and since there is no alternate
yyyy/dd/mm format the DB never gets confused. You can use a function like
this:
www.adopenstatic.com/resources/code/formatdate.asp to meet all your date and
time formatting needs.

HTH

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Peter Foti (PeterF)" <PeterF@S...>
Subject: [asp_databases] RE: Here's a good one - Date/Time issues.


: Right, but my question is this... how does FormatDate know that 5/10/2001
: does not represent May 10th instead of Oct. 5?  When FormatDate is called
: using "5/10/2001", does this function always assume that the input is in
the
: format d/m/y?
:
: -Pete

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message #2 by "Drew, Ron" <RDrew@B...> on Wed, 17 Jul 2002 12:01:25 -0400
http://www.adopenstatic.com/faq/systemdateformat.asp

-----Original Message-----
From: Peter Foti (PeterF) [mailto:PeterF@S...]
Sent: Wednesday, July 17, 2002 11:15 AM
To: ASP Databases
Subject: [asp_databases] RE: Here's a good one - Date/Time issues.


One thing I dont understand...

dteDate =3D "5/10/2001" ' 5th October, 2001
dteDate =3D FormatDate(dteDate, "%Y/%m/%d") ' dteDate =3D "2001/10/05"

How does it know that 10 is the month and not the day?  In this example,
the start date is in d/m/y format (although we only know that based on
the comment, there is no code that specifies this).  But what if it was
in m/d/y format?  Would the FormatDate function yeild different results?

-Pete


> -----Original Message-----
> From: Greg Harvey [mailto:greg.harvey@w...]
> Sent: Wednesday, July 17, 2002 4:00 PM
> To: ASP Databases
> Subject: [asp_databases] RE: Here's a good one - Date/Time issues.
>
>
> Thanks a lot. That works. Still doesn't explain why the thing
> so suddenly
> stopped working, but at least I have a fix. :)
>
> Greg.
>
>
>
> > Take a look at this solution:
> http://www.adopenstatic.com/faq/DateswithAccess.asp
>
> -Kim
>

Message #3 by "Craig Flannigan" <ckf@k...> on Wed, 17 Jul 2002 16:20:21 +0100
Because it's the international date format.

If the Year is the first in the date string, then it's treated as
International - yyyy/mm/dd


-----Original Message-----
From: Peter Foti (PeterF) [mailto:PeterF@S...]
Sent: 17 July 2002 16:15
To: ASP Databases
Subject: [asp_databases] RE: Here's a good one - Date/Time issues.


One thing I dont understand...

dteDate = "5/10/2001" ' 5th October, 2001
dteDate = FormatDate(dteDate, "%Y/%m/%d") ' dteDate = "2001/10/05"

How does it know that 10 is the month and not the day?  In this example, the
start date is in d/m/y format (although we only know that based on the
comment, there is no code that specifies this).  But what if it was in m/d/y
format?  Would the FormatDate function yeild different results?

-Pete


> -----Original Message-----
> From: Greg Harvey [mailto:greg.harvey@w...]
> Sent: Wednesday, July 17, 2002 4:00 PM
> To: ASP Databases
> Subject: [asp_databases] RE: Here's a good one - Date/Time issues.
>
>
> Thanks a lot. That works. Still doesn't explain why the thing
> so suddenly
> stopped working, but at least I have a fix. :)
>
> Greg.
>
>
>
> > Take a look at this solution:
> http://www.adopenstatic.com/faq/DateswithAccess.asp
>
> -Kim
>


_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service on behalf of
Kingfield Heath Ltd. For further information visit
http://www.star.net.uk/stats.asp


_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service on behalf of Kingfield Heath Ltd. For further information visit
http://www.star.net.uk/stats.asp
Message #4 by "Peter Foti (PeterF)" <PeterF@S...> on Wed, 17 Jul 2002 11:34:16 -0400
Right, but my question is this... how does FormatDate know that 5/10/2001
does not represent May 10th instead of Oct. 5?  When FormatDate is called
using "5/10/2001", does this function always assume that the input is in the
format d/m/y?

-Pete


> -----Original Message-----
> From: Craig Flannigan [mailto:ckf@k...]
> Sent: Wednesday, July 17, 2002 11:20 AM
> To: ASP Databases
> Subject: [asp_databases] RE: Here's a good one - Date/Time issues.
> 
> 
> Because it's the international date format.
> 
> If the Year is the first in the date string, then it's treated as
> International - yyyy/mm/dd
> 
> 
> -----Original Message-----
> From: Peter Foti (PeterF) [mailto:PeterF@S...]
> Sent: 17 July 2002 16:15
> To: ASP Databases
> Subject: [asp_databases] RE: Here's a good one - Date/Time issues.
> 
> 
> One thing I dont understand...
> 
> dteDate = "5/10/2001" ' 5th October, 2001
> dteDate = FormatDate(dteDate, "%Y/%m/%d") ' dteDate = "2001/10/05"
> 
> How does it know that 10 is the month and not the day?  In 
> this example, the
> start date is in d/m/y format (although we only know that based on the
> comment, there is no code that specifies this).  But what if 
> it was in m/d/y
> format?  Would the FormatDate function yeild different results?
> 
> -Pete
> 
> 
> > -----Original Message-----
> > From: Greg Harvey [mailto:greg.harvey@w...]
> > Sent: Wednesday, July 17, 2002 4:00 PM
> > To: ASP Databases
> > Subject: [asp_databases] RE: Here's a good one - Date/Time issues.
> >
> >
> > Thanks a lot. That works. Still doesn't explain why the thing
> > so suddenly
> > stopped working, but at least I have a fix. :)
> >
> > Greg.
> >
> >
> >
> > > Take a look at this solution:
> > http://www.adopenstatic.com/faq/DateswithAccess.asp
> >
> > -Kim
> >
> 
> 
> _____________________________________________________________________
> This message has been checked for all known viruses by Star Internet
> delivered through the MessageLabs Virus Scanning Service on behalf of
> Kingfield Heath Ltd. For further information visit
> http://www.star.net.uk/stats.asp
> 
> 
> _____________________________________________________________________
> This message has been checked for all known viruses by Star Internet
> delivered through the MessageLabs Virus Scanning Service on 
> behalf of Kingfield Heath Ltd. For further information visit 
> http://www.star.net.uk/stats.asp
> 
> 
Message #5 by "Greg Harvey" <greg.harvey@w...> on Wed, 17 Jul 2002 16:00:28
Thanks a lot. That works. Still doesn't explain why the thing so suddenly 
stopped working, but at least I have a fix. :)

Greg.



> Take a look at this solution:
http://www.adopenstatic.com/faq/DateswithAccess.asp

-Kim
Message #6 by "Kim Iwan Hansen" <kimiwan@k...> on Wed, 17 Jul 2002 16:44:20 +0200
Take a look at this solution:
http://www.adopenstatic.com/faq/DateswithAccess.asp

-Kim

> -----Original Message-----
> From: greg.harvey@w... [mailto:greg.harvey@w...]
> Sent: 17. juli 2002 14:42
> To: ASP Databases
> Subject: [asp_databases] Here's a good one - Date/Time issues.
>
>
> I'm writing a date to an Access database with a SQL string. SQL string is:
>
> SQLString = "INSERT INTO chat (f_date) VALUES (#" & Date & "#)"
>
> From 13/07/2002 onwards (yes - I'm using British date/time format on a
> British server) my database or SQL queries have started screwing up. It
> isn't affecting the running of the scripts, but it's very weird.
>
> The date was being stored fine in the database as 12/07/2002 but on the
> 13th it flipped to storing 02/07/2013, 14th became 02/07/2014,
> etc. - it's
> flipping the year and the month around. Now instead of storing DD/MM/YYYY
> it's storing YY/MM/YYDD!
>
> Oddly enough, the database is still returning data in the right format to
> the browser in ASP - just storing it wrong. Also, I have other
> applications running on the same and other servers using the same
> code and
> they're fine.
>
> If it started flipping the DAY and the month around I'd expect that
> (American format date issue or something), but YEAR and month?! Any ideas
> anybody? Please!
>
> Greg.

Message #7 by greg.harvey@w... on Wed, 17 Jul 2002 14:41:56
I'm writing a date to an Access database with a SQL string. SQL string is:
 
SQLString = "INSERT INTO chat (f_date) VALUES (#" & Date & "#)"

From 13/07/2002 onwards (yes - I'm using British date/time format on a 
British server) my database or SQL queries have started screwing up. It 
isn't affecting the running of the scripts, but it's very weird.
 
The date was being stored fine in the database as 12/07/2002 but on the 
13th it flipped to storing 02/07/2013, 14th became 02/07/2014, etc. - it's 
flipping the year and the month around. Now instead of storing DD/MM/YYYY 
it's storing YY/MM/YYDD!
 
Oddly enough, the database is still returning data in the right format to 
the browser in ASP - just storing it wrong. Also, I have other 
applications running on the same and other servers using the same code and 
they're fine.
 
If it started flipping the DAY and the month around I'd expect that 
(American format date issue or something), but YEAR and month?! Any ideas 
anybody? Please!

Greg.
Message #8 by "Peter Foti (PeterF)" <PeterF@S...> on Wed, 17 Jul 2002 11:14:49 -0400
One thing I dont understand...

dteDate = "5/10/2001" ' 5th October, 2001
dteDate = FormatDate(dteDate, "%Y/%m/%d") ' dteDate = "2001/10/05"

How does it know that 10 is the month and not the day?  In this example, the
start date is in d/m/y format (although we only know that based on the
comment, there is no code that specifies this).  But what if it was in m/d/y
format?  Would the FormatDate function yeild different results?

-Pete


> -----Original Message-----
> From: Greg Harvey [mailto:greg.harvey@w...]
> Sent: Wednesday, July 17, 2002 4:00 PM
> To: ASP Databases
> Subject: [asp_databases] RE: Here's a good one - Date/Time issues.
> 
> 
> Thanks a lot. That works. Still doesn't explain why the thing 
> so suddenly 
> stopped working, but at least I have a fix. :)
> 
> Greg.
> 
> 
> 
> > Take a look at this solution:
> http://www.adopenstatic.com/faq/DateswithAccess.asp
> 
> -Kim
> 

  Return to Index