Solved

DateAdd year in SSRS expression

Posted on 2013-02-06
6
13,008 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
[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
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

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

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

737 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