0

i need a function to do something like this:

select datediff(  '2016-01-01', '2015-01-01') 

but ignoring some days, example :

calculate the interval between 2 dates only Mondays and Thursdays ignoring the other days

I do not want to make an select at the DB, only calculate the number of days between dates

sorry my English

PM 77-1
  • 12,933
  • 21
  • 68
  • 111
  • 1
    which db you are using ? – shaikh Dec 11 '15 at 18:42
  • 1
    he is not native english, so i think he couldnt express himself better, consider it – Tiago P.C Dec 11 '15 at 18:44
  • As @Siyual said this is not a code writing service, but to point you in the right direction. It is not usually difficult to take the number of days, divide by seven & mod by seven, then examine the days of the week the first & last days were (comparing to the remainder) to determine whether to add 1 to the quotient. – Uueerdo Dec 11 '15 at 18:48
  • [This post](http://stackoverflow.com/questions/9757919/count-days-between-two-dates-excluding-weekends-mysql-only) deals with excluding weekends, so it should be a good reference for your purposes. – PM 77-1 Dec 11 '15 at 18:51
  • @PM77-1 - then there's this one: http://stackoverflow.com/questions/833261/mysql-week-calcualtion-between-two-dates - he can just multiply by 2. – user3741598 Dec 11 '15 at 21:22

0 Answers0