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

avoid default day 1/1/1900 1

Status
Not open for further replies.

fanghua

Programmer
Feb 11, 2004
28
US
every time i insert a record, if i don't specify date or '', it will always have 1/1/1900 in the db. this has cause a lot of error and confusion. what's the suggestion to avoid this.... thanks!
 
What do you want it to be?

I do not believe you can make DATETIME/SMALLDATETIME NULLable. So you have to enter something.

You could ALTER the column to have a default of whatever you might want.

-SQLBill
 
You can make a datetime field nullable.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Whenever you are inserting the record you should check the condition on the date variable and Insert NULL.

For example

If request("datevar")<>"" Then

SQL= "INSERT INTO TABLENAME(datevar) VALUES('"&request("datevar")&"')"

Else

SQL= "INSERT INTO TABLENAME(datevar) VALUES(NULL)"

End IF


Hope that helps

Thanks

VJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top