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

DaysBetween

Status
Not open for further replies.

i257156

Programmer
Sep 25, 2002
12
0
0
GB
I know that I am being really thick.. However, I need this syntax pretty quick and I haven't got time to go to the quacks to get some memory pills!

When adding a variable to count the days between is it possible to count the number of working days between? If so how the heck do you do it!!??
Thanks
JB
 
You should test this, but I think it would work.

daysbetween=(int(days(date2) - days(date1))/7)*5 +
if dayofweek(date2) >= dayofweek(date1) then dayofweek(date2) - dayofweek(date1)
else
dayofweek(date1) - dayofweek(date2) - 2

It converts the dates to an integer number of days, treats whole weeks as 5 days, then adjusts for the differenece of day of week.

The exact syntax will depend on the database in use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top