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

Record Selection YTD in Jan I want last Year's data 2

Status
Not open for further replies.

JC442

MIS
Apr 19, 2004
34
US
This is a classic problem in monthly reporting. I want the report to select records Year to Last Month when it is run in February through December. In January, I want to report the prior full year.

I'm sure there is an elegant solution.
 
If Month(CurrentDate)=1 then {YourDateField} in Date(2004,1,1) to Date(2004,1231)

else

{YourDateField} in date(2005,1,1) to Date(2005,12,31)

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports
 
Or to skip hardcoding:
Code:
If Month(CurrentDate) = 1
Then Year({YourDate}) = Year(CurrentDate)-1
and {YourDate} in YearToDate
Else 
{YourDate} in YearToDate
Naith
 
Sorry, I thought you wanted data up to the current date.

For data a month in arrears, you'll have to amend the above formula to:
Code:
If Month(CurrentDate) = 1
Then Year({YourDate}) = Year(CurrentDate)-1
Else 
{YourDate} in Date(Year(CurrentDate),1,1) to (CurrentDate - Day(CurrentDate))
Naith
 
Many Thanks to you both.

It may be my own vanity, but I'm hoping these reports will run for many years to come. I'm going to skip the hard coding.

Very Best Regards,
Jim



 
I use the following for my YTD record selection.

Code:
{table.date} in dateserial(year(minimum(lastfullmonth)),1,1) to maximum(lastfullmonth)

-LW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top