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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rotating Year Formula???

Status
Not open for further replies.

PQTIII

IS-IT--Management
Sep 21, 2004
110
0
0
I want to run a report that captures data with a date range of today's date from the same day but a year ago. I guess I'm looking for a rotating year each time the report is ran. What is the best way to accomplish this???

Thanks
Paul
CR9
 
Try
Code:
{field.date} = DateAdd ("y", -1, {currentdate})
I'm not sure how this would cope with leap-years. A fancier alternative would be
Code:
if DatePart("d", {currentdate}) <> 29
or Month({currentdate}) <> 2
then {field.date} = Date((year({currentdate})-10), month({currentdate}), DatePart("d", {currentdate}))
else
{field.date} = Date((year({currentdate})-10), month({currentdate}), DatePart("d", {currentdate}))-1

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Correction, use currentdate rather than {currentdate}.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top