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 |
|
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2005-03-21 : 06:46:28
|
| There is a nullable datefield called DateFixed.if it is showing 1900-01-01 I would like to return '' as shown below, but it returns 1900-01-01 00:00:00.000 instead.How do i alter this sql for my purpose please?Thanks'DateFixed' = case when DateDiff(day, DateFixed, '1900-01-01') = 0 then '' else DateFixed end, |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-03-21 : 07:57:45
|
so what's wrong with:'DateFixed' = casewhen DateFixed = '1900-01-01' then '' -- you can optionally add 00:00:00 else DateFixedend,Go with the flow & have fun! Else fight the flow |
 |
|
|
dev45
Yak Posting Veteran
54 Posts |
Posted - 2005-03-21 : 07:58:08
|
| i think u have to convert the datefixed field in the else clause to varchar. This works but it makes a conversion to the way the datefixed field is shown (maybe u can find another conversion that suits your needs)'DateFixed' =casewhen DateDiff(day, DateFixed, '1900-01-01') = 0 then ''else convert(varchar(10),DateFixed, 103)end |
 |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2005-03-21 : 08:09:37
|
| If Null is shown (where?) as '1900-01-01' then'DateFixed' =casewhen DateFixed is null then ''else convert(varchar(10),DateFixed, 103)end |
 |
|
|
|
|
|