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

Working Days

Status
Not open for further replies.

Bunting

MIS
Mar 19, 2002
50
GB
I have a report which is to run every Weekday (monday through to Friday).

The report will run in the evening and pick up all transactions for the currentdate; my select expert therefore reads (Transaction.date = Currentdate)

The problem I have is that on a monday I need the report to pick up data for the saturday and sunday as well...

How can i tell the select expert to do the following ....

If weekday in Tue/Wed/Thur/Fri then (Transaction.date = Currentdate)
else if its Monday then (Transaction.date in (Currentdate-3) to currentdate ?
 
Hi Bunting,

The logic is almost exactly as you've stated. You'll just have to make the following tweaks:

If DayOfWeek(CurrentDate) in [3 to 6]
Then Transaction.date = Currentdate
Else
If DayOfWeek(CurrentDate) = 2
Then Transaction.date in [Currentdate-2 to CurrentDate]

All the best,

Naith
 
You could try this:

if dayofweek(currentdate) = 2 then {Transaction.Date} in
currentdate-2 to currentdate else
{Transaction.Date} = currentdate

-LB
 
These formulas may not pass the SQL to the database, so your performance will suffer (I tested using CR 8.5 - check Database->Show SQL Query).

For best results, please post the database type, data types and Crystal version.

In this case you'll probably want to create a start date, and make it a datetime within a formula, as in:

// Formula @startdate
if dayofweek(currentdate) = 2 then
cdatetime(year(currentdate-2 ),month(currentdate-2 ),day(currentdate-2 ),0,0,0)
else
cdatetime(year(currentdate),month(currentdate),day(currentdate),23,59,59)

Then reference this formula from the select expert manually (Report->Edit Selection Formula->Record and place:

{Bob.Order Date} >= {@startdate}

Change {bob.order date} to your date field.

-k
 
Ive just tested V9 and

if dayofweek(currentdate) = 2 then {Transaction.Date} in
currentdate-2 to currentdate else
{Transaction.Date} = currentdate

does pass SQL to the database.

Hooray for version 9.........

Reebo
Scotland (Sunny with a Smile)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top