cancel
Showing results for 
Search instead for 
Did you mean: 

Pull date range from parameter

Former Member
0 Kudos

So I have a formula that has hard coded date ranges in it.

Whileprintingrecords;

shared numbervar YTDQTY;

if {ARHDRH.Invoicedate} in date(2010, 01, 01) to date(2010, 12, 31)

then {ARLINH.Qtyshipped}

I also have another formula that is basically the same thing, just for last year.

I would like to modify this formula and have it grab the dates that are entered in a date range parameter. I then could take this and just subtract a year off it, this way the user can just enter in whatever dates they choose and it will also subtract one year. I just don't know how to have to grab my parameters date. I remember seeing a formula kind of like this

DateValue (year(minimum({?DateRange}))

But I tried entering it in like so

DateValue (year(minimum({?DateRange})) to DateValue (year(maximum({?DateRange}))

And it just said that I am forgetting the ")"

Any ideas?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Assuming that you are using a range type date parameter... Try this:


if {ARHDRH.Invoicedate} in Minimum({?DateParameter} to Maximum({?DateParameter})
then {ARLINH.Qtyshipped}

HTH,

Jason

Former Member
0 Kudos

Yeah that was does calculate, that is the one I tried earlier. I still run into the problem on subtracting a year though.

Former Member
0 Kudos

Try this...


if {ARHDRH.Invoicedate} in DateAdd("yyyy", -1, Minimum({?DateParameter})) 
to DateAdd("yyyy", -1, Maximum({?DateParameter}))
then {ARLINH.Qtyshipped}

Former Member
0 Kudos

That worked!

Thanks for the assistance! I think this will work good. This gives them the option to run for whatever years they choose. I was able to pull the year off the date range so as long as they don't span across multiple years this should be good.

Thanks again!

Former Member
0 Kudos

No problem. Glad you got working the way you wanted it to work.

Former Member
0 Kudos

I actually spoke too soon. After going through the pages there is no data in my prior year column. The parameter is only grabbing invoices from the date range entered. I think I may have to about this from a different angle.

Former Member
0 Kudos

Typically, if you're trying to do a side by side comparison of 2 distinct years, you'll be better off using a couple of sub reports that simply feed off of the same parameter. One that pulls the previous year and one that pulls the current year. the 2 reports can then be placed side by side.

Other wise you end up stacking the results on top of each other... Which can work for you if you just want to group the results by year.

Former Member
0 Kudos

I think that may be the best bet. It may decrease in performance but I think this is really the only other option considering what the user wants.

Thanks for help!

Answers (1)

Answers (1)

Former Member
0 Kudos

I tried changing it to this.

Whileprintingrecords;

Shared Numbervar YTDPrice;

{ARHDRH.Invoicedate} in date (minimum({?date}) to ((maximum({?date})

but it still says I am missing the ")" it wants to place it at the end of the formula, but if i do that I get prompted again.

Former Member
0 Kudos

So far I didn't get any errors when i tried this

Whileprintingrecords;

shared numbervar YTDQTY;

if {ARHDRH.Invoicedate} in minimum({?date}) to maximum({?date})

then

{ARLINH.Qtyshipped}