Solved

DateAdd year in SSRS expression

Posted on 2013-02-06
6
11,330 Views
Last Modified: 2013-02-06
I have a field on my SSRS report with this as the expression...
= DATEADD ("y", -1, Today())  & " to " & Today()

It runs and displays 2/5/13 to 2/6/13

What I want is to subtract a year so I want 2/5/12 to 2/6/13.  It appears to be subtracting just one day.  Please tell me what I'm missing?
0
Comment
Question by:BobRosas
  • 3
  • 3
6 Comments
 
LVL 37

Expert Comment

by:ValentinoV
ID: 38861299
Try this:

= DATEADD (YEAR, -1, Today())  & " to " & Today()
0
 

Author Comment

by:BobRosas
ID: 38861318
Thank you for you quick reply.  I tried your code above and the report won't even run.  I get the error that "interval is not valid".  I also tried "yy" and it runs but just has an error where the date should be.  I also tried Now() instead of Today() but the date doesn't change it just adds the time.
0
 
LVL 37

Accepted Solution

by:
ValentinoV earned 250 total points
ID: 38861330
Hmm, okay, how about this:

=DATEADD(DateInterval.Year, -1, Today())  & " to " & Today()
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:BobRosas
ID: 38861354
YES!  Thank you!  I would not  have gotten that!
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 38861373
Cool, glad I could help! I didn't have SSRS around to try it out so needed two attempts this time.  Come to think of it, I do indeed always use that DateInterval.  If you type it in the expression builder, once you enter the dot it should show a list of possibilities...
0
 

Author Comment

by:BobRosas
ID: 38861381
Good to know!  Thank you so much!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Hi, I have heard from my friends that it’s not possible to create Label Printing report using SSRS. I am amazed after hearing this words not possible in SSRS. I googled lot and found that it is possible to some of people know about the Report Bui…
Introduction In the following article I’ll be discussing and demonstrating several different ways of how images can be put on a report. I’m using SQL Server Reporting Services 2008 R2 CTP, more precisely version 10.50.1352.12, but the methods ex…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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