YearToDate function for past years?

Posted on 2006-05-18
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
    LVL 42

    Accepted Solution

    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

    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

    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

    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

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    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…
    Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now