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!

grouping dates - crystal reports V9 MIS

Status
Not open for further replies.
Nov 23, 2006
22
GB
Hi, hope you can help.

I am trying to group a datetime field into "current month", "previous month" and ">previous months"

e.g current - January 2007
Previous - December 2006
>Previous - November back to 2004

this is what I have so far, but I can't work out how to get >previous months without writing it out long hand,-2,-3 etc

if (month({@DUE_DATE}) = Month (currentdate)
AND YEAR ({@DUE_DATE}) = YEAR (CURRENTDATE))
then "CURRENT MONTH"

ELSE if {@DUE_DATE} in
dateserial(year(currentdate),month(currentdate)-1,1)
to_
dateserial(year(currentdate),month(currentdate),1)
then "PREVIOUS MONTH
 
Is there some sort of limit to how far back "> previous months" will go back?
You mention 2004. Does this mean it's always Jan 1, 2004?



Bob Suruncle
 
ELSE if {@DUE_DATE} <
dateserial(year(currentdate),month(currentdate)-1,1)
then "PREVIOUS MONTHS"

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top