Count days within a month from date range

Posted by G. Muqtada on Stack Overflow See other posts from Stack Overflow or by G. Muqtada
Published on 2013-10-18T09:36:43Z Indexed on 2013/10/18 9:54 UTC
Read the original article Hit count: 114

Filed under:
|
|

I have three date ranges in mysql table as follow

  • from 2013-09-29 to 2013-10-02
  • from 2013-10-14 to 2013-10-16
  • from 2013-10-28 to 2013-11-05

I want to count only days that occur in Month of October, for example from first range (2013-09-29 to 2013-10-02) I should get difference of two days (1st and 2nd October) , and it should ignore days from September month, Finally i want to count total days in a given month from above date ranges.

Can it be done from direct mysql query. or any short PHP logic.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql