Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This date last year... 1

Status
Not open for further replies.

rayna

Programmer
Sep 24, 2001
54
0
0
CA
Am using 8.5, and am looking to put three columns, side by side - Budget, Actual, and Last Year Actual. The last year actual is in the same table as the current actual, and therefore the only way I can figure out how to do it is by subreport and shared variable.

The thing is, I can't figure out how to get a "same date last year" date.

I wrote this, but I am pretty sure it's wrong.

datevar dateLastYear;

if (Year(CurrentDate)) mod 4 = 0 then
dateLastYear := CurrentDate - 366
else
dateLastYear := CurrentDate - 365;

dateLastYear;

Anyone know a less amateur, more precise way to do this?

Thanks!!
Rayna

Man plans. God laughs.
 
If you mean the amounts for last year and this are in the same field, you don't really need a subreport. You could use formulas like:

//{@lastYTD}:
if {table.date} in date(year(currentdate)-1,01,01) to dateserial(year(currendate)-1,month(currentdate)+1,01)-1 then {table.amt}

//{@Ytd}:
if {table.date} in YearToDate then {table.amt}

Place these in the detail section and then right click on each and insert summaries on them. Then suppress the detail section.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top