Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Razzle00
Starting Member
35 Posts |
Posted - 2007-03-14 : 12:09:38
|
| Hi, Is it possible to have a datetime field that does not except null values contain an empty date? When I update the field with an empty string like '', it always puts 01/01/1900 in there.UPDATE MyTable SET MyDate = ''Thanks,Razzle |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2007-03-14 : 12:21:06
|
| Short answer is no.What is happening is that SQL is converting '' to 0.Try:SELECT CAST(0 AS DATETIME)-Ryan |
 |
|
|
VincentFrandsen
Starting Member
39 Posts |
Posted - 2007-03-15 : 09:32:39
|
| I recon if you want to put a null value or '' into the DB then create the column alowing nulls or is that not possible?otherwize let that date 01 01 1900 and search for it in your select and retun that data back as ''Vincent Fradnsen |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-15 : 09:46:15
|
if you really want, you can use trigger or check constraints to validate this KH |
 |
|
|
Razzle00
Starting Member
35 Posts |
Posted - 2007-03-16 : 08:45:57
|
| Thanks for the tips. I think I will just accept the date as 01/01/1900 and in my application return an empty string whenever I read a date equal to that. It will take some extra coding steps, but that should work. It seems to me that it would make more sense if SQL server would at least accept 00/00/0000 00:00:00 for a datetime. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-16 : 08:48:07
|
| Use NULL for that.Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|