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!

Datediff (business hours and weekdays only)

Status
Not open for further replies.

jdemmi

MIS
Jun 6, 2001
1,106
US
I am comparing 2 date fields (minutes between) using the datediff function. My formula is working correctly, but now I need to further constrain the time calcultated between the 2 dates.

Currently I have:
datediff("n",{TBL1.Date1},({TBL1.Date2})).

I need to only consider business hours and weekdays. Is there any way (easy or not) to do this?

According to CR help file, I should be able to restrict it to weekdays (in their example below) but it does not seem to be working for me. However, even if it does work I am not sure how I can restrict the calculation to business hours (8 to 5) only.

Here is the CR example for restricting to weekdays:
//Crystal syntax
Local DateTimeVar d1 := {Orders.Order Date};
Local DateTimeVar d2 := {Orders.Ship Date};
DateDiff ("d", d1, d2) -
DateDiff ("ww", d1, d2, crSaturday) -
DateDiff ("ww", d1, d2, crSunday)

Any ideas?


-- Jason
"It's Just Ones and Zeros
 
take a look at this thread

thread767-891598

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top