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 2005 Forums
 Analysis Server and Reporting Services (2005)
 Display blank when the date is in default value

Author  Topic 

Limuh
Yak Posting Veteran

94 Posts

Posted - 2009-03-03 : 05:44:31
Hello-

I want to get the value in date that stored in my database and i want to display '' if the date are in a default value in my database '1900-01-01 00:00:00' im having a problem in expression. please help

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-03 : 05:58:48
NULLIF(Col1, 0)



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Limuh
Yak Posting Veteran

94 Posts

Posted - 2009-03-03 : 06:07:16
I used this expression =IIf(IsNothing(Fields!End_Date.Value),0,Fields!End_Date.Value) but it doesn't change the 1/1/1900 12:00:00 AM date to blank
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-03 : 06:31:08
For that, you have to convert date to string,

=IIf(CDate(Fields!End_Date.Value) = #1900-01-01#, "", "" & Fields!End_Date.Value)



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Limuh
Yak Posting Veteran

94 Posts

Posted - 2009-03-03 : 06:38:48
wow! this is great thanks you peso. but i have another concern my date is displaying in this format 12/31/2009 and i want it to display as 31-Dec-2009 i know its in the format how should i do that?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-03 : 06:40:12
=IIf(CDate(Fields!End_Date.Value) = #1900-01-01#, "", Format(Fields!End_Date.Value, "dd-MMM-yyyy"))



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Limuh
Yak Posting Veteran

94 Posts

Posted - 2009-03-03 : 06:45:55
Thank you Peso! :) but i made little changes on the expression to replace "" to nothing to treat it in excel as date when we sort. Thanks again!
=IIf(CDate(Fields!End_Date.Value) = #1900-01-01#, Nothing, Format(Fields!End_Date.Value, "dd-MMM-yyyy"))
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-03 : 12:40:45
you dont have to do this inside data cell. just use the below in expression window of the format tab of your cell window

=IIF(Me.Value =#1900-01-01#,Nothing,"dd-MMM-yyyy")
Go to Top of Page

Limuh
Yak Posting Veteran

94 Posts

Posted - 2009-03-03 : 21:26:41
what are the difference of the two? i got an error om Me.Value?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-04 : 09:52:56
where did you give it? inside format tab textbox in cell properties as i suggested?
Go to Top of Page

Limuh
Yak Posting Veteran

94 Posts

Posted - 2009-03-09 : 04:16:56
i did excatly the code you gave.. and i have a question what is the difference between "" and Nothing? because it did not match the same result? example when i use "" i got 5 and when i used NOTHING i got 4? i make the the records IsNull(number,'').. my column having a records of blank and Null.. Thank you.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-10 : 04:26:51
"" means blank value. Nothing is same as NULL
Go to Top of Page
   

- Advertisement -