Where I work:
1) We created a table for holidays (projected data for the next few years).
2) Created a function for the day of the week.
3) If M-F and not Holiday, then perform routine.

We had to go this route because there are way too many bank and market
holidays to keep straight with just code.  Plus, it is flexible in the event
of change (i.e. 9/11 - the markets were closed for several days, so they do
not count as business days).

Hope this helps.

Bruce



----- Original Message -----
From: "Patrick Näf" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Joe Stump" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 2:21 PM
Subject: Re: # of Business Days?


> Hello
>
> This is not correct, see this at example:
>  From friday to mondey there are 4 days (or 3, depends on how you count
;-).
> your calcs:
> $day = 4
> $weeks = 4 / 7 = 0
> $weekend_day = 0 * 2 = 0
> $business_days = 4 - 0 = 4
>
> If you have 100 weeks, then it will be quite correct.
>
> here is my solution:
>
> $day = total_days_between_a_and_b;
> $less = weekend_days_between_WeekDAY_a_and_WeekDAY_b (for example: from
> friday to Mondey, then it will be 2)
> $weeks = $day DIV 7;
> $bussiness_days = $day - $weeks * 2 - $less;
>
> my example again:
> $day = 4;
> $less = 2;
> $weeks = 0;
> $bussiness_days = 4 - 0 * 2 - 2 = 2
>
> or use a function from a programming language, if available. You have to
> deal also with some special days (12-24 / 12-25 and so on).
>
> greetings from Switzerland
>
> Patrick
>
> Joe Stump wrote:
>
> >I'm not sure of an exact query, but if you can get the total number of
days
> >you can mathmatically get the biz days with the following math (in psuedo
> >code):
> >
> >$days = total_days_between_a_and_b;
> >$weeks = ($days / 7);
> >$weekend_days = $weeks * 2;
> >$business_days = ($days - $weekend_days);
> >
> >Hope this helps. There may be more elegant ways of getting such a value.
> >This doesn't take into account day A being wednesday. You might be able
to
> >do a SELECT COUNT(*) on evaluating your date to it's Day value in
> >('Mon','Tue','Wed','Thu','Fri')
> >
> >Check the date commands.
> >
> >--Joe
> >
> >
> >--
> >Joe Stump <[EMAIL PROTECTED]>
> >http://www.joestump.net
> >"Label makers are proof God wants Sys Admins to be happy."
> >
> >-----Original Message-----
> >From: Lucas Cowgar [mailto:[EMAIL PROTECTED]
> >Sent: Monday, February 24, 2003 9:59 AM
> >To: MySQL Mailing List
> >Subject: # of Business Days?
> >
> >
> >Can anyone out there help me with a SQL query? I need to find the number
of
> >business days between date a and b? Obviously finding simply the number
of
> >days is easy, but I have no clue how to find the number of business days.
> >TIA!
> >
> >
> >Lucas Cowgar
> >Information Technologies Department
> >Eldorado Services Group Inc.
> >http://www.eldoserv.com
> >[EMAIL PROTECTED]
> >(330) 861-3009
> >
> >"All your base are belong to us"
> >
> >
> >---------------------------------------------------------------------
> >Before posting, please check:
> >   http://www.mysql.com/manual.php   (the manual)
> >   http://lists.mysql.com/           (the list archive)
> >
> >To request this thread, e-mail <[EMAIL PROTECTED]>
> >To unsubscribe, e-mail
> ><[EMAIL PROTECTED]>
> >Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
> >
> >
> >---------------------------------------------------------------------
> >Before posting, please check:
> >   http://www.mysql.com/manual.php   (the manual)
> >   http://lists.mysql.com/           (the list archive)
> >
> >To request this thread, e-mail <[EMAIL PROTECTED]>
> >To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> >Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to