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

LastYearYTD and YearToDate functions

Status
Not open for further replies.

bessebo

IS-IT--Management
Jan 19, 2001
766
US
I am using the above functions in a report but my boss wants to be able to run this report at a specific point in time. In other words, can I hardcode a date saying that I am really running this report say on 12/31/2001 rather than today, 2/1/2002 and still use the functions above. This report uses the current date and time and computes everything in the LastYearYTD and YearToDate buckets based on the current date and time. I would like to be able to prompt for a date and have the report run based on that date and have the LastYearYTD and YearToDate buckets populated accordingly.

Bessebo
 
I would abandon those 2 functions and create 2 formula fields: last year and this year. the formulas should read, respectively, If year({datefield})=Year(Currentdate)-1 then {amount} else 0 and If year({Datefield}) = Year(CurrentDate) then {amount} else 0.

This of course will give you BOTH YEARS, in their entirety. To restrict that to the records you are interested in, create a date parameter and then input the following record selection formula:

{Datefield} in Date(Year({?Parmfield}),1,1)) to {?Parmfield}
or {Datefield} in Date(Year({?Parmfield})-1,1,1)) to Dateadd("y",-1,{?Parmfield})

The first part of the statement covers the current year, up to the parameter field, and the second covers the prior year up until one year before the parameter field date to achieve a LastYearYTD and YearToDate equivalent based on your parameter answer. Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top