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!

How to set selection criterion for a specific range of datetime 1

Status
Not open for further replies.

Barock21

MIS
Dec 27, 2005
23
US
Hello all,

I am currently using crystal 8.5 and am trying to create a delivery report.
This report will be printed everyday. However, it needs to retrieve information from 11:46am the previous day through 8:45am today. As far as, Monday - I need to have it from 11:46am Friday to 8:45am Monday.

Obviously, this can be solved easily using prompts or setting up the parameters manually. However, I'd like to set this up so that my users don't need to do anything other than pressing the button and the report automatically prints the information based on that parameter.
I figured out on how to do this based on days using DayOfWeek function. But I can't simply get how to get the time correctly. Any advice will be greatly appreciated. Thanks in advance.
 
You mean it executes 5 days, not every day, otherwise why would you have Friday thru Monday on Monday?

You'll need a datetime parameter, then it should be simple enough:

record selection formula:


if dayofweek = 2 then
(
{table.date} >= dateserial(year(currentdate),month(currentdate),day(currentdate)-3) + time(11,46,0)
and
{table.date} <= dateserial(year(currentdate),month(currentdate),day(currentdate)) + time(8,45,0)
)
else
(
{table.date} >= dateserial(year(currentdate),month(currentdate),day(currentdate)-1,11,46,0)
and
{table.date} <= dateserial(year(currentdate),month(currentdate),day(currentdate),8,45,0)
)

I may not have the concatenation of the date and time correct here as I'm going from memory, but the theory is sound, it just might need a slight tweak to get it to see the date and time together properly.

-k
 
Oh, I should have mentioend that you don't need a datetime parameter since I based it off of the currentdate.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top