Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    1

    Unanswered: How to calculate working days between two dates??

    How to calculate working days between two dates??

    If 2 dates are taken.
    E..g Date 1--> 16/09/2204
    Date 2--> 22/09/2004

    How to calculate no. of working days between these 2 dates?
    (i.e. Excluding Sat. & Sun.)

    I tried writing UDF. But didn't got what to define in shared library can anybody help me in this problem. Also how to write FOR loop in mysql??

  2. #2
    Join Date
    Aug 2004
    Location
    France
    Posts
    754
    Hello,

    Try this :

    SELECT datefield FROM table WHERE DATE_FORMAT(datefield, '%W') NOT IN ('Saturday', 'Sunday');

    For more info on date functions, please refer to the mysql manual.

    Concerning loops, you can't do that in SQL, so I think you will have to do that in an external program (C++, Java, Php... depending on your needs).

    Regards,

    RBARAER

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •