Count days without week-end
Posted in 2000
Topics: General Discussion
Hallo, We want to count the days between 2 dates in 2 ways: * all the days: select '2000.09.26' - '2000.09.22' + 1 from systables where tabid = 1; Result ist 5 days ... no problem! * the days without the week-end: Result must be 3 (Friday, Monday, Tuesday) How can I do this? The interval between the 2 dates can be more than 1 year. Many thanks for good ideas Philippe Juillot
philippe juillot wrote: > We want to count the days between 2 dates in 2 ways: > > * all the days: > select '2000.09.26' - '2000.09.22' + 1 from systables where tabid > = 1; > Result ist 5 days ... no problem! > > * the days without the week-end: > Result must be 3 (Friday, Monday, Tuesday) > How can I do this? The interval between the 2 dates can be more > than 1 year. The file busdays in the ESQL/C section of the Software Archive at the IIUG web site (http://www.iiug.org) contains code to count the number of business days between two dates. There's a dummy function to count the number of holidays between two dates that returns zero -- you can tailor it to handle actual public (or private) holidays using any convention you choose. For example, you could decide that there's a table which lists the national holidays for any given country, but as soon as you go multi-national, it starts to get tricky. Anyway, the dummy routine gives you the answer you want -- the number of Monday-Friday days between two dates. It is ESQL/C code; it can be translated into SPL but I have not been motivated to do so. -- Yours, Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h> Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN "I don't suffer from insanity; I enjoy every minute of it!"