473,395 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ASP > SQL date problem!?

Hi,

I know this is an old problem and I've already tried to look the
solution up on the web but I didn't find what I need.

So, there's the following situation:

I've got an ASP page with a form, containing two fields that poses problems

1. birthday field
SQL server will only accept it if entered in MM/DD/YYYY. Which is bad
since we're in Europe, people are accustomed to DD/MM/YYYY. I tried to
use LCID but that didn't work either. Funny thing is when the birthday
is entered in MM/DD/YYYY on the page, it later gets displayed as
DD/MM/YYYY in SQL Server!? Which is good though! (It would be better of
course if it could be entered in DD/MM/YYYY and be recorder in SQL as such)

2. field with the current date & time
The ASP page displays it correctly as 02/09/2004 (September 2nd). But
SQL Server saves it as 09/02/2004 (February 9th). And I bet there'll be
an error or September 13th ... Or is there a way to define in SQL Server
something similar to the Default Value: Now() in Access? Then I could
drop this field on the ASP page.

So somehow there's a complete confusion!?

How can I streamline that or where on the Internet could I find more
info about it?

Thank you very much,

Jerome
Jul 19 '05 #1
6 2183
Jerome wrote on 02 sep 2004 in microsoft.public.inetserver.asp.general:
1. birthday field
SQL server will only accept it if entered in MM/DD/YYYY.
No, the general accepted format is yyyy-mm-dd
Which is bad
since we're in Europe, people are accustomed to DD/MM/YYYY. I tried to
use LCID but that didn't work either. Funny thing is when the birthday
is entered in MM/DD/YYYY on the page, it later gets displayed as
DD/MM/YYYY in SQL Server!?
SQL server does not "display"
Which is good though! (It would be better
of course if it could be entered in DD/MM/YYYY and be recorder in SQL
as such)
In a database field with the type date(!!), as you are using here,
the date is stored as a number.
2. field with the current date & time
The ASP page displays it correctly as 02/09/2004 (September 2nd). But
SQL Server saves it as 09/02/2004 (February 9th).
You should "give" it to the SQL string as yyyy-mm-dd or yyyy/mm/dd
And I bet there'll
be an error or September 13th ... Or is there a way to define in SQL
Server something similar to the Default Value: Now() in Access? Then I
could drop this field on the ASP page.
Perhaps, I do not use SQL server. now() will probably include the actual
serverlocal time. I suspect that is not what you want.

But if you 'give' it to the db as a ASP string, convert your input to a
yyyy-mm-dd string

If you retrieve it from the databas, and it comes as mm/dd/yyyy, convert
it by ASP(vbs/jscript) to you preferred string.
So somehow there's a complete confusion!?

How can I streamline that or where on the Internet could I find more
info about it?


Concluding:

Make two functions,
one converting your preferred date string to a yyyy-mm-dd string
and
one converting the database output string to your preferred date string.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 19 '05 #2
Jerome wrote:
Hi,

I know this is an old problem and I've already tried to look the
solution up on the web but I didn't find what I need.

So, there's the following situation:

I've got an ASP page with a form, containing two fields that poses
problems
1. birthday field
SQL server will only accept it if entered in MM/DD/YYYY.
Wron. SQL Server will also accept the ISO standard date:

YYYYMMDD
Which is bad
since we're in Europe, people are accustomed to DD/MM/YYYY. I tried to
use LCID but that didn't work either. Funny thing is when the birthday
is entered in MM/DD/YYYY on the page, it later gets displayed as
DD/MM/YYYY in SQL Server!?
No it doesn't. Datetimes are stored without format as paired integers: the
first integer containing the number of days since the seed date, and the
second containing the number of milliseconds since midnight (to indicate
time of day). Any formatting is done by the client tool used to retrieve the
date from the database, usually using the Regional Settings for the user as
the default format (although this varies depending on which client tool you
are using to retrieve the dates).
Which is good though! (It would be better
of course if it could be entered in DD/MM/YYYY and be recorder in SQL
as such)
You should always pass dates to SQL Server in a non-ambiguous format (the
ISO standard). If you allow users to enter dates in any way they wish, you
need to reformat them to YYYYMMDD before passing them to SQL. You need to
take control of the display process so the dates will be displayed in your
preferred format. See the links below.

2. field with the current date & time
The ASP page displays it correctly as 02/09/2004 (September 2nd). But
SQL Server saves it as 09/02/2004 (February 9th). And I bet there'll
be an error or September 13th ... Or is there a way to define in SQL
Server something similar to the Default Value: Now() in Access? Then
I could drop this field on the ASP page.


Again, this is entirely dependant on the Regional Settings for the IUSR
account on your web server machine. See these articles:

http://www.aspfaq.com/show.asp?id=2313 vbscript
http://www.aspfaq.com/show.asp?id=2040 help with dates
http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #3
>> And I bet there'll
be an error or September 13th ... Or is there a way to define in SQL
Server something similar to the Default Value: Now() in Access? Then I
could drop this field on the ASP page.
Perhaps, I do not use SQL server. now() will probably include the actual
serverlocal time. I suspect that is not what you want.


set default value for column to GETDATE() (SQL Server) [or SYSDATE (Oracle)]

http://msdn.microsoft.com/library/de...ga-gz_4z51.asp
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29... Jerome wrote on 02 sep 2004 in microsoft.public.inetserver.asp.general:
1. birthday field
SQL server will only accept it if entered in MM/DD/YYYY.


No, the general accepted format is yyyy-mm-dd
Which is bad
since we're in Europe, people are accustomed to DD/MM/YYYY. I tried to
use LCID but that didn't work either. Funny thing is when the birthday
is entered in MM/DD/YYYY on the page, it later gets displayed as
DD/MM/YYYY in SQL Server!?


SQL server does not "display"
Which is good though! (It would be better
of course if it could be entered in DD/MM/YYYY and be recorder in SQL
as such)


In a database field with the type date(!!), as you are using here,
the date is stored as a number.
2. field with the current date & time
The ASP page displays it correctly as 02/09/2004 (September 2nd). But
SQL Server saves it as 09/02/2004 (February 9th).


You should "give" it to the SQL string as yyyy-mm-dd or yyyy/mm/dd
And I bet there'll
be an error or September 13th ... Or is there a way to define in SQL
Server something similar to the Default Value: Now() in Access? Then I
could drop this field on the ASP page.


Perhaps, I do not use SQL server. now() will probably include the actual
serverlocal time. I suspect that is not what you want.

But if you 'give' it to the db as a ASP string, convert your input to a
yyyy-mm-dd string

If you retrieve it from the databas, and it comes as mm/dd/yyyy, convert
it by ASP(vbs/jscript) to you preferred string.
So somehow there's a complete confusion!?

How can I streamline that or where on the Internet could I find more
info about it?


Concluding:

Make two functions,
one converting your preferred date string to a yyyy-mm-dd string
and
one converting the database output string to your preferred date string.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 19 '05 #4
Thomas Dodds wrote on 02 sep 2004 in
microsoft.public.inetserver.asp.general:
And I bet there'll
be an error or September 13th ... Or is there a way to define in SQL
Server something similar to the Default Value: Now() in Access? Then
I could drop this field on the ASP page.


Perhaps, I do not use SQL server. now() will probably include the
actual serverlocal time. I suspect that is not what you want.


set default value for column to GETDATE() (SQL Server) [or SYSDATE
(Oracle)]

http://msdn.microsoft.com/library/de...y/en-us/tsqlre
f/ts_ga-gz_4z51.asp
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Jerome wrote on 02 sep 2004 in
microsoft.public.inetserver.asp.general:
1. birthday field
SQL server will only accept it if entered in MM/DD/YYYY.


No, the general accepted format is yyyy-mm-dd
Which is bad
since we're in Europe, people are accustomed to DD/MM/YYYY. I tried
to use LCID but that didn't work either. Funny thing is when the
birthday is entered in MM/DD/YYYY on the page, it later gets
displayed as DD/MM/YYYY in SQL Server!?


SQL server does not "display"
Which is good though! (It would be better
of course if it could be entered in DD/MM/YYYY and be recorder in
SQL as such)


In a database field with the type date(!!), as you are using here,
the date is stored as a number.
2. field with the current date & time
The ASP page displays it correctly as 02/09/2004 (September 2nd).
But SQL Server saves it as 09/02/2004 (February 9th).


You should "give" it to the SQL string as yyyy-mm-dd or yyyy/mm/dd
And I bet there'll
be an error or September 13th ... Or is there a way to define in SQL
Server something similar to the Default Value: Now() in Access? Then
I could drop this field on the ASP page.


Perhaps, I do not use SQL server. now() will probably include the
actual serverlocal time. I suspect that is not what you want.

But if you 'give' it to the db as a ASP string, convert your input to
a yyyy-mm-dd string

If you retrieve it from the databas, and it comes as mm/dd/yyyy,
convert it by ASP(vbs/jscript) to you preferred string.
So somehow there's a complete confusion!?

How can I streamline that or where on the Internet could I find more
info about it?


Concluding:

Make two functions,
one converting your preferred date string to a yyyy-mm-dd string
and
one converting the database output string to your preferred date
string.


Certainly not topposting, nor interposting, nor topquoting.
Thomas, wat is this?

Now() I am sure you ment well,
just forgot to delete the bottom part.

;-}

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 19 '05 #5
CJM
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:OW*************@TK2MSFTNGP11.phx.gbl...

Wron. SQL Server will also accept the ISO standard date:

YYYYMMDD


I agree with your advice, Bob, but I'm uneasy about the use of the word
'Standard'.

ISO 8601 states that the standard date format is YYYY-MM-DD, but then goes
on the explain that other delimiters are acceptable as is their omission.

So YYYYMMDD, YYYY-MM-DD and YY-MM-DD are all 'standard' date formats that
meet the ISO 8601 requirements. If you add a time element, as is often
important in DB work then you have further variations still, eg.
YYYY-MM-DDTHH:MM:SS.

Unfortunately, different DB's only accept a subset of the valid formats! So
there's often no way to code some SQL that is truly portable.

Further reading:
RFC3339
ISO8601
etc...

Not quite as straightforward as it should be, perhaps?

Chris
Jul 19 '05 #6
right - pick on me for having the tech skills to answer the question ....
Certainly not topposting, nor interposting, nor topquoting.
Thomas, wat is this?

Now() I am sure you ment well,
just forgot to delete the bottom part.

;-}

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jason | last post by:
I need to deposit and empty dummy value into a date/time field within Access using INSERT. However, I pick up a data type error if I attempt to insert a NULL value for this particular date time...
6
by: Piotr Pietrowski | last post by:
Hello everybody, I have a *big* problem. I thought its not that big problem for you professionals... Anyway, I have a begin date which has 3 dropdown boxes (day/Month/Year). The same for the...
3
by: Piotre Ugrumov | last post by:
I have done the overload on the operator >> and << in the class Attore. These 2 overload work correctly. I have done the overload of the same overload in the class Film. The class film ha inside...
2
by: bissatch | last post by:
Hi, I am currently writing a simple PHP program that uses an XML file to output rows for a 'Whats New' page. Once written, I will only require updating the XML file and any pages that use the...
1
by: Marc Boucher | last post by:
I'm using PG 7.3.4 I've a table with a column of type int8 where I store date-based values, and an index exists for it. The problem is that the index is almost never used with the '>' test. #...
4
by: David Lozzi | last post by:
Howdy, I'm using a WYSIWYG editor called TinyMCE. When I edit some text and then save it back to my SQL server using a SQLCommand, all HTML characters are changed to HTML code, i.e. &gt;strong&lt;...
6
by: Piotr | last post by:
Hi, I have following problem: I use a form in excel to send data into mysql server, everything is ok unless I have to deal with decimals or data fields, this simple are not recognized. For...
0
by: compumate99 | last post by:
I am trying to parse the xml document using selectsinglenode method. I am doing this using Visual Foxpro >>> loResultXml = CreateObject("Microsoft.XMLDOM") With loResultXml .Async = .F. ...
13
by: Mark | last post by:
Dear folks, In Javascript, is it possible to get all id names within, say, a <div></divpair? Like the array of "document.images", I mean. The reason I ask, is that I have a calender whose...
21
by: py_genetic | last post by:
Hello, I'm importing large text files of data using csv. I would like to add some more auto sensing abilities. I'm considing sampling the data file and doing some fuzzy logic scoring on the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.