[thelist] 1/1/1900 SQL Server/ASP Question

David@softv.net David at softv.net
Wed Jan 16 15:12:43 2002


If the date value you'll always be submitting is the present date you can
use SQL Server's GETDATE() function in your SQL String, or better yet, set
it as the default value for that field in the DB.

Dave

-----Original Message-----
From: Scott Schrantz [mailto:scotts@rci-nv.com]
Sent: Wednesday, January 16, 2002 3:15 PM
To: 'thelist@lists.evolt.org'
Subject: RE: [thelist] 1/1/1900 SQL Server/ASP Question


> -----Original Message-----
> From: josh [mailto:evolt@efeingold.com]

> I am updating a database field via a web form.  When a date 
> is placed in the field the database updates correctly.  When
> the form is left blank, the database assumes the value 1/1/1900. 
> 
> Does anyone know what I have done wrong? 

You need to put some logic in your code to deal with someone leaving the
date blank.

<code snippet type="revised">

ID = request.form("id")

If request.form("the_date") = "" Then
	TheDate = Date()  'Or whatever default date you want
Else
	TheDate = request.form("the_date")
End If

rs.Open "UPDATE t_table SET t_cr_ccss_review_date = '" & 
TheDate & "' WHERE id=" & ID

</code snippet> 

It's always a good idea to dump form fields into variables first, so you can
clean them up and validate them before passing them on to your SQL
statements.

-- 
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt !