Wrox Home  
Search P2P Archive for: Go

  Return to Index  

proasp_howto thread: date always 1900-01-01


Message #1 by patrick.frenette@s... on Thu, 21 Feb 2002 21:04:40
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <patrick.frenette@s...>
Subject: [proasp_howto] date always 1900-01-01


: I have some problems saving my dates right in my SQL DB from an ASP page.
: Whatever i do, it stores 1900-01-01.
:
: strSQL = "INSERT INTO Person date_creation VALUES (" & date & ")"
: conn.Execute(strSQL)

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

...Because you are using incorrect delimiters.

You are doing 2/22/2002, which is a mathematical expression that can be
described as 2 divided by 22 divided by 2002, which is a very small number.
SQL Server uses whole numbers to express the number of days since 1/1/1900
(for small date time), and the decimal portion to express the portion of the
day that has passed. Since 2/22/2002 is approx 0.000045 the date is recorded
as 1/1/1900

You need to use ' around dates to indicate that they are literal dates, not
mathematical expressions to be evaluated by SQL Server.

Cheers
Ken



  Return to Index