[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SSRS Date evaluation problem

Posted on 2013-01-07
4
Medium Priority
?
937 Views
Last Modified: 2013-01-07
I have the following code

=IIf(Fields!Freeze.Value, Fields!effectivedate.Value, IIF(Month(Fields!effectivedate.Value) <> Month(Now()), Format(Now(), “MM/dd/yyyy”) , Fields!effectivedate.Value))



A. In the first IIF statement I check to see if the Fields!Freeze.Value is true, if its true then It displays Fields!effectivedate.Value  (IIf(Fields!Freeze.Value, Fields!effectivedate.Value)

B. In the second IIF statemenet I check if the Fields!effectivedate.Value is the current month, If it is the current month then it displays Fields!effectivedate.Value, If it is not the current month then it displays the current date.


I would like assistance on the following.

In the first IIF statement ,>>> IIf(Fields!Freeze.Value, Fields!effectivedate.Value,
I want to evaluate a new value  Fields!FreezeDate.value


1. If the Fields!Freeze.Value = true then  check to see if the Fields!effectivedate.Value is 30 days or more less than Fields!FreezeDate.value.
   A.  If its 29 days or less than Fields!FreezeDate.value then display Fields!effectivedate.Value
   B.  If its 30 days or more less than the Fields!FreezeDate.value then display the Fields!FreezeDate.value


Example 1

     Fields!FreezeDate.value  = '12/30/2012'
     Fields!effectivedate.Value = '11/15/2012'


     then Display the Fields!FreezeDate.value


Example 2

     Fields!FreezeDate.value  = '12/30/2012'
     Fields!effectivedate.Value = '12/15/2012'


     then Display the Fields!effectivedate.Value


How would I write this in SSRS code?




Please ask for further clarification if i have failed to explain something properly.
0
Comment
Question by:michiganblkman
  • 2
  • 2
4 Comments
 
LVL 37

Expert Comment

by:ValentinoV
ID: 38750844
You can use the DateDiff function to get the difference between two dates.  Have a look at the following expression:

=DateDiff(DateInterval.Day, CDate("2012-12-30"), CDate("2012-11-15"))

That would return the difference, in days, between those two dates. Because the first one is later than the second one the result, -45, is negative.

The above should give you something to get started with your expression enhancement.

DATEDIFF (MSDN)
0
 

Author Comment

by:michiganblkman
ID: 38751286
yes ValentinoV,

I have so far DateDiff(DateInterval.Day, Fields!effectiveDate.Value, Fields!FreezeDate.Value) < 30
    , Fields!effectiveDate.Value
    , Fields!FreezeDate.Value

Because this is a paid forum, I didnt think I would be out of line to ask for an answer outright.


I am interested in seeing how others would tackle this problem.
0
 
LVL 37

Accepted Solution

by:
ValentinoV earned 2000 total points
ID: 38751993
Who said something about being out of line?  I surely didn't?  But it's not because it's a paid forum that you should expect others to do your work for you.  That's what they've invented consultancy for.  Besides, it might be a paid forum but the experts here are all volunteers who just like doing this stuff.  Or in other words: it doesn't hurt to think a bit as well, you might learn something while at it.  Don't worry though, we've all got the same goal in mind: to help you solve your issue!

The expression you posted will work as long as effective date is always smaller (earlier) than freeze date, is that the case?  If yes, in full your expression would become something like this:

=IIf(Fields!Freeze.Value, 
	IIF(DateDiff(DateInterval.Day, Fields!effectiveDate.Value, Fields!FreezeDate.Value) < 30
		, Fields!effectiveDate.Value
		, Fields!FreezeDate.Value),
	IIF(Month(Fields!effectivedate.Value) <> Month(Now())
		, Format(Now(), “MM/dd/yyyy”)
		, Fields!effectivedate.Value))

Open in new window

0
 

Author Comment

by:michiganblkman
ID: 38752191
Thanks for your view on things.  FYI, I have been a member here since 2002 back when it was free.  Since 2004 i have been a paid member. In that time i have asked 16 questions. I havent done the math on what over 8 years of membership fees/16 questions ratio is.  So I guess I would hardly consider myself a person that "gets others to do the work for me" since i have only presented 16 questions to this forum since 2002.     I only ask here when I truly dont have time to figure something out.  

Thanks for your answer.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question