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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 string to datetime conversion

Author  Topic 

raddy
Starting Member

12 Posts

Posted - 2008-05-30 : 10:12:58
Hi,
Ive imported a data set into SQL. Now on redefining a text field to datetime, most dates that are filled come through okay.

The issue is that there are some empty fields which I'd like for it to stay empty after conversion. Now what happens is that the empty field becomes '01/01/1900' - which is throwing off our queries as we need it to be compared to other date fields.

Is there a way to keep it empty even after the datatype is changed to datetime?
Thanks a bunch!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-30 : 10:28:00
How are you converting them to datetime? Using CAST?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-05-30 : 10:28:38
You cant have empty value in a datetime column. Better update them to NULL

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

raddy
Starting Member

12 Posts

Posted - 2008-05-30 : 10:35:46
quote:
Originally posted by madhivanan

You cant have empty value in a datetime column. Better update them to NULL

Madhivanan

Failing to plan is Planning to fail



Yes, so could I just go ahead and do an UPDATE?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-05-30 : 10:39:22
quote:
Originally posted by raddy

quote:
Originally posted by madhivanan

You cant have empty value in a datetime column. Better update them to NULL

Madhivanan

Failing to plan is Planning to fail



Yes, so could I just go ahead and do an UPDATE?


yes

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

raddy
Starting Member

12 Posts

Posted - 2008-05-30 : 10:51:41
Thank you all, it works :)
Go to Top of Page
   

- Advertisement -