Re: Counting days
Posted in 1996
Paul Watyson (ifpxw@ifl.co.uk) wrote:
: I want to count the number of weekdays between the dates
: using only sql.
There's probably a clever algorithm using MOD 7 and subtracting 2 for
every 7 days, but this will work:
SELECT COUNT(*)
FROM table
WHERE date_column BETWEEN "start_date" AND "end_date"
AND WEEKDAY(date_column) IN (1,2,3,4,5)
(WEEKDAY() returns INTEGER, 0=Sunday, 6=Saturday)
=======================================================================
Dennis J. Pimple dennisp@informix.com Opinions expressed
Principal Consultant -------------------- are mine, and do not
Informix Software Inc Voice: 303-850-0210 necessarily reflect
Denver Colorado USA Fax: 303-779-4025 those of my employer.
: Anybody got any ideas
: Thank in advance
: Paul Watson
: International Factors Ltd