compare two dates

Hello,

I am working on some logic to compare two dates, of the order type "outbound" if the dates do'nt match then I need to apply a yellow background to both cells. if one of the two dates is null, no yellow background should be apply.

i tried this, but is not working:
=IIF(
	Fields!Type.Value = "Outbound" AND 
	Fields!NAVShipmentDate.Value <> "" AND	
	Fields!NAVShipmentDate.Value <> Fields!TranDate.Value, "Yellow", "White"
	)

Open in new window


i highlighted the cells that should be yellow based on logic. i hope someone can help me with this logic.

screen shot
thank you much.
metropiaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chaauCommented:
Use ISNULL for the empty dates:

=IIF(
	Fields!Type.Value = "Outbound" AND 
	!IsNull(Fields!NAVShipmentDate.Value) AND	
	Fields!NAVShipmentDate.Value <> Fields!TranDate.Value, "Yellow", "White"
	)

Open in new window

0
ValentinoVBI ConsultantCommented:
I'd go for something like this:

=IIF(Fields!Type.Value = "Outbound",
	Switch(
		IsNothing(Fields!NAVShipmentDate.Value) or IsNothing(Fields!TranDate.Value), "White",
		Fields!NAVShipmentDate.Value <> Fields!TranDate.Value, "Yellow",
		true, "White"
	)
	, "White"
)

Open in new window

BTW: instead of "White" you can also specify "No Color".  There's a slight difference because No Color is transparent while White is white...

chaau: SSRS expressions don't have an IsNull function, you may have meant IsNothing?  Furthermore, the "not" operator is Not, not exclamation mark.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.