Solved

SSRS Date evaluation problem

Posted on 2013-01-07
4
914 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now