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

Query Last 30 Days, 60 Days etc...

Status
Not open for further replies.

qcman

Technical User
Jul 20, 2004
30
US
I'm using Crystal 8.5,In the select expert Crystal allows a user to query in the period of "thelast7days". I want to run a query for the period of "Last 30 Days" or "Last 60 Days" etc...
 
You can do it using DateAdd("d", -60, {your.date}) etc.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
That isn't working for me. I entered the following in the select expert: dateadd ("d", -60, {TA_WO_INFORMATION.WO_FINISH_DATE}) and I got the following error message "a boolean is required here."
Keep in mind, I want to display all the information from today minus 60 days. Thanks for your help and quick response.
 
Maybe DateAdd("d", -60, currentdate) > {your.date}. Or maybe start again in a new formual field. I remember that 8.5 would sometimes get a fixed notion that a formula field ought to be a boolian, and refuse to change.

Boolians are tests without an 'IF'. They can be tested for 'true' or false, or just invoked by name.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I think you need to compare the result of the dateadd function to a date field as Madawc posted.

You can also use some of the Date Range Functions:

{table.date} in Aged0to30days //to get dates within the 30 days

{table.date} in minimum(Aged0to30days) to maximum(Aged31to60days) //to get dates within the 60 days


~Brian
 
Thanks everyone but I figured it out through many trials and errors. I used the following:
{TABLE.DATE} in (Aged0To30Days + Aged31To60Days + Aged61To90Days)
 
You could also write it this way and there would be less conditions to check in the SQL Query

{table.date} in minimum(Aged0to30days) to maximum(Aged61to90days)

~Brian
 
Brian,

That would need to be:

{table.date} in minimum(Aged61To90Days) to maximum(Aged0To30Days)

...since the aging works in reverse. I was just testing what passed to the SQL Query and noticed this--I initially thought it would work the way you laid it out, also.

-LB
 
Something simpler such as:
Code:
CurrentDate - {table.date} < 90
would work as well.

- Ido

Visual CUT & DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top