If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > How to calculate working days between two dates??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-16-04, 07:10
chinmayogale chinmayogale is offline
Registered User
 
Join Date: Sep 2004
Posts: 1
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??
Reply With Quote
  #2 (permalink)  
Old 09-16-04, 07:25
RBARAER RBARAER is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On