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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Case Else w/Date isssue

Author  Topic 

TallOne
Starting Member

49 Posts

Posted - 2006-08-15 : 09:42:46
Ok here's my query.
Select ExpectedDeliveryDate = Case When Convert(char(10), OutForDeliverydate, 101) = '01/01/1900' Then '' Else OutForDeliveryDate End From tbl....
Now when I run this, I still get a return value of
1900-01-01 00:00:00.000 but would expect ''?????? TIA

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-08-15 : 09:51:08
[code]
Select ExpectedDeliveryDate = Case When Convert(char(10), OutForDeliverydate, 101) = '01/01/1900' Then Null Else OutForDeliveryDate End From tbl....
[/code]

WHen you specify '' then it takes the default date i.e. 1900-01-01 00:00:00.000

Chirag
Go to Top of Page

TallOne
Starting Member

49 Posts

Posted - 2006-08-15 : 10:20:42
Oh. I was expecting '' since I was converting to varchar. Thanks for the enlightenment!
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-08-15 : 10:24:58
aha then it should be somthing like this


Declare @var Table
(
dt SmallDateTime
)
Insert @var
Select '01/01/1900' Union All
Select GetDate()

Select Case When dt = '01/01/1900' then '' Else Convert(varchar(10),dt,101) End As Tmp From @var




Chirag
Go to Top of Page

TallOne
Starting Member

49 Posts

Posted - 2006-08-15 : 10:39:53
Dang I'm backwards again! That resolved my issue! Thanks you!
Go to Top of Page
   

- Advertisement -