Skip to Content
author's profile photo Former Member
Former Member

Subtracting 1 year from a single Parameter that prompts for a date range

I have a single parameter that prompts the user for a date range.

I can display the values from the prompt, but I'd also like to display the values for the same period one year in the past.

For instance if the user enters 1/1/2014 to 5/30/2014 I want to display 1/1/2013 to 5/30/2013.

Thanks for the help.


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jun 11, 2014 at 10:46 PM

    hi Wade,

    try something like this in your Report > Selection Formula > Record editor...substituting the fields and parameters for your own...

    {Orders.Order Date} in {?DateRange}


    {Orders.Order Date} in dateadd('yyyy', -1, minimum({?DateRange})) to dateadd('yyyy', -1, maximum({?DateRange}))

    the above doesn't really handle leap years in the calc, but you'd need to specify exactly what kind of logic you'd want to use when a leap year comes into play.

    you could also use something like this

    {Orders.Order Date} in {?DateRange}



    {Orders.Order Date} >= date(year(minimum({?DateRange}))-1, month(minimum({?DateRange})), day(minimum({?DateRange}))) and

    {Orders.Order Date} <= date(year(maximum({?DateRange}))-1, month(maximum({?DateRange})), day(maximum({?DateRange})))


    check the Database menu > Show SQL Query to see how these two are processed, especially with leap years...i.e. enter 02/29/2016 as the start date to your parameter. you'll need to figure out how you want to handle these exceptions.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.