Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SSRS Date evaluation problem

Posted on 2013-01-07
4
Medium Priority
?
935 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

636 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