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

Record Selection Using Date Range

Status
Not open for further replies.

khdavis

Technical User
Mar 27, 2002
22
US
Hi All! Hope someone can help... I'm using Crystal 10. I have a report I'd like to schedule so I can't use parameters.

When the report runs it needs to pull in data from the previous Thursday, 8PM to the current Thursday, 8PM. For instance, if the report runs Friday(6/10), it's pulls in data from Thurs (6/2), 8PM to Thurs(6/9), 8PM or if it runs Wednesday(6/15) it still pulls in data from Thurs (6/2), 8PM to Thurs(6/9), 8PM.

Hope that's clear. Can I do this? Thanks...
 
If you are always wanting the previous week and assuming {table.date} is in datetime format, then try this

Code:
{table.date} in
 [DateTime(minimum(LastFullWeek)+4,TIME(20,0,0)) to
  DateTime(maximum(LastFullWeek)+5,TIME(20,0,0))]

-lw
 
Scheduling does not preclude the use of parameters.

Set a default value in the datetime parameter (make it a date range type) such as 1/1/1970

Then in your record selection formula use:

(
if {?MyDateParm} <> cdate(1970,1,1) then
{table.date} >= minimum({?MyDateParm})
and
{table.date} <= maximum({?MyDateParm})
else
if {?MyDateParm} = cdate(1970,1,1) then
{table.date} in
[DateTime(minimum(LastFullWeek)+4,TIME(20,0,0)) to
DateTime(maximum(LastFullWeek)+5,TIME(20,0,0))]

Used kskids solution for the second half rather than recoding.

This will allow the report to default to the Thursday criteria, however you can overide it by running the report and manually placing in dates.

-k
 
Thanks for your help! Both solutions worked great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top