Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Blank out empty dates
Message
 
 
To
14/11/2006 13:52:08
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01169592
Message ID:
01169596
Views:
8
This message has been marked as the solution to the initial question of the thread.
>Hi,
>
>I've got a VFP application querying a SQL Server 2005 database.
>
>Some date fields on the server are 'blank' (i.e. 1900-01-01 00:00:00.000)
>
>How can I query the data but pull out a truly blank value?
>
>I would guess something like this:
>
>SELECT cast(case when edc_ddepart = '1900-01-01 00:00:00.000' then '' else edc_ddepart end as [datetime]) as edc_ddepart
>
>But that isn't doing what I expect. Or is it that what I am trying to do is wrong and I should be using NULL values for blank dates?

The SQL Server doesn't support empty dates. The CAST('' AS datetime) will return 1900-01-01 00:00:00.000. The NULLs is a proper way to represent blank/unknown dates in SQL Server.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform