YearToDate function for past years?

Posted on 2006-05-18
Medium Priority
Last Modified: 2010-05-18
How do I right a formula to retrieve YTD data for past years, I know the function for last year is LastYearYTD but what about prior years like 2004 and 2003, etc.  I assume this has to be fairly simple and straight forward but I can't seem to figure it out.

If {trade.settle_i} in LastYearYTD-1 Then

Thanks for your help!

Question by:IO_Dork
  • 3
  • 2
LVL 42

Accepted Solution

frodoman earned 1000 total points
ID: 16710569
One way is to add a year to 2004 (making it 2005) and then do a LastYear comparison:

  if DateAdd('yyyy',1,{trade.settle_i}) in LastYearYTD then ...
LVL 42

Expert Comment

ID: 16710592
Or a more generic formula that compares the month & day regardless of year:

   if DATE(year(currentdate), month({trade.settle_i}), day({trade.settle_i}) < currentdate then ...


Author Comment

ID: 16710909
I am not sure if it makes a difference but I want to show YTD for the last five years or so, i.e. - this year 2006, along with 2005, 2004, 2003, 2002, 2001 and 2000.  Does your first formula work in this case?
LVL 42

Expert Comment

ID: 16711816
No, you'd have to do +1 Or +2, etc.  The second formula however will work for every year so if you want to see everything you can use this formula as is.  If you want year 2000+ then do this (I assume you want this in the record selection formula?):

year({trade.settle_i}) >= 2000
DATE(year(currentdate), month({trade.settle_i}), day({trade.settle_i}) < currentdate

Author Comment

ID: 16712054
i used the first formula for all years and it worked great! Thanks!

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

750 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