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!

Trying to enter Null in DateTime column

Status
Not open for further replies.

stacy47

Programmer
Jan 24, 2001
6
US
Using SQL 7. When I try to pass a null value to a stored procedure which adds a new record, the value inserted into a datetime field is Jan 01, 1900. Have tried almost every conditional programming to force the null value, but to no avail. Any suggestions would be greatly appreciated. Thank you.
 
The secret is, do not insert any value for the date column.

Code:
CREATE TABLE nullsOnly (
id CHAR(10),
birthday DATETIME
)

INSERT INTO nullsOnly (id)
   VALUES ('xxx')

SELECT * FROM nullsOnly
 
If you pass only a time to a datetime field, then you get 1/1/1900 as the date.

It depends how the datetime field was defined in the table. If it was defined as allowing NULLs, then you don't have to pass anything to it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top