Solved

SSRS Date evaluation problem

Posted on 2013-01-07
4
924 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 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

820 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