MySQL : Calculate business day difference between two dates column

Posted by yokoyoko on Stack Overflow See other posts from Stack Overflow or by yokoyoko
Published on 2012-11-12T21:56:47Z Indexed on 2012/11/12 23:01 UTC
Read the original article Hit count: 159

Filed under:
|

My sql query returns back two columns, first column is "date created" and second column is "date updated", first column has a prior timestamp with respect to second column.

I need to add a third column which can display business day hrs (9:00am to 5:00pm) response i.e. if date created is 2012-01-01 09:00:20 and "dated updated" is 4:00pm same day then third column should display 7 hrs

If date created is 2012-01-01 16:00:20 (4:00pm) and "date updated" is 10:00m on 2012:01:02 (2nd Jan) then third column should display 2 hrs.

It should exclude Saturday and Sunday.

Can you please suggest appropriate SQL query for this.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql