YearToDate function for past years?

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.

Example:
If {trade.settle_i} in LastYearYTD-1 Then
            {trade.prin_i}
Else
            0



Thanks for your help!

Brian
IO_DorkAsked:
Who is Participating?
 
frodomanConnect With a Mentor Commented:
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 ...
0
 
frodomanCommented:
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 ...

0
 
IO_DorkAuthor Commented:
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?
0
 
frodomanCommented:
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
and
DATE(year(currentdate), month({trade.settle_i}), day({trade.settle_i}) < currentdate
0
 
IO_DorkAuthor Commented:
i used the first formula for all years and it worked great! Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.