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

how can I code a criteria to be current date minus 6 months?

Status
Not open for further replies.

matpj

Technical User
Mar 28, 2001
687
GB
as per subject line, I have a criteria which currently requires the user to pick a date from a calender.
this then selects all records before that date.

how can I code Crystal to use current date minus 6 months, rather than having the user select the date?

thanks,


Matt
London (UK)
 
This should do it:
DateAdd("m", -6,CurrentDate)

The DateAdd function returns a DateTime, so if you need it to be a Date, you can cast it like this:
CDate(DateAdd("m", -6,CurrentDate))

-dave
 
If you want six months to the date, then

{TABLE.DATE} >= dateadd("m",6,currentdate)

Or

If you want from the first of the month

{table.date) >= dateserial(year(currentdate),month(currentdate)-6,1)

Cheers,

-LW
 
Oops forgot the sign

{TABLE.DATE} >= dateadd("m",-6,currentdate)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top