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!

Want Datediff minus the weekends

Status
Not open for further replies.

lokiloki

Programmer
May 31, 2001
5
0
0
CA
I need to calculate the number of days between a start date and an end date but I only want weekdays included. I need some code that will take out the weekends.
 
Hi,
Recently I had to do similar thing but in Visual FoxPro so I got this function that you call with your start and end date
** Date1,Date2 are arguments to this function**
ldStartDate= IIF(Date1> Date2,Date2,Date1)
ldEndinDate = IIF(Date1=> Date2,Date1,Date2)
lnNumberOfDays = ldEndinDate - ldStartDate
lnReturnDays = lnNumberOfDays

FOR iDays = 1 TO lnNumberOfDays
IF DOW(ldStartDate + iDays) < 7 AND ;
DOW(ldStartDate + iDays) > 1
lnReturnDays = lnReturnDays
ELSE
lnReturnDays = lnReturnDays - 1
ENDIF
ENDFOR

RETURN lnReturnDays

Hope this helps
Lyn
 
It often starts with this. It usually esclates to exclude Holidays after a REALLY short interval (the fisrt HOLIDAY period).

look at faq181-261

It shows how to do it all. If you want to wait for the 'User Community' to whine, snivel and complain about the HOLIDAYS, use the faq soloution anyway. Just make an empty holiday table.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top