SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 IIF help subtracting dates.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

hbadministrator
Posting Yak Master

120 Posts

Posted - 01/14/2014 :  12:01:18  Show Profile  Reply with Quote
Need help with color flag.

I have a field that gets current date =Globals!ExecutionTime and another 2 fields that have the month and year. =Fields!BudgetPrd.Value and =Fields!BudgetYear.Value.

What I am trying to accomplish is current month and year minus budget prd and year must be greater than 2 months apart for me to flag the field yellow. For the life of me I can't figure anyway to write this. example would be 1/14/2014 - 10/2013 is more than 2 months so flag that record. Any help would be greatly appreciated.

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 01/15/2014 :  07:09:50  Show Profile  Reply with Quote
set below expression for background color
=IIF(DateDiff(DateInterval.Month,DateSerial(Cint(Fields!BudgetYear.Value),Cint(Fields!BudgetPrd.Value),Cint(1)),Globals!ExecutionTime)> 2 ,"yellow","None")

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

hbadministrator
Posting Yak Master

120 Posts

Posted - 01/16/2014 :  08:49:51  Show Profile  Reply with Quote
here is the message I get.

The BackgroundColor expression for the text box ‘BudgetPrd’ contains an error: Input string was not in a correct format.
=IIF(DateDiff(DateInterval.Month,DateSerial(Cint(Fields!BudgetYear.Value),Cint(Fields!BudgetPrd.Value),Cint(1)),Globals!ExecutionTime)> 1 ,"yellow","White")

I changed the 2 to a 1 just to see if it was working correctly but still didn't show anything.
Go to Top of Page

hbadministrator
Posting Yak Master

120 Posts

Posted - 01/16/2014 :  10:56:22  Show Profile  Reply with Quote
ok so actually to get it to show correct answer it would need to be take they year x 12 then add the month. Then take current year x12 +current month. if difference is >2 then yellow.
Go to Top of Page

hbadministrator
Posting Yak Master

120 Posts

Posted - 01/16/2014 :  11:19:49  Show Profile  Reply with Quote
=IIF((Year(Today)*12+Month(Today))-((Fields!BudgetYear.Value)*12+(Fields!BudgetPrd.Value))>2,"yellow","White") This is the answer to my question Thank you Visakh16
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000