mysql - SQL query to filter saturday and sunday -
i have complex sql query calculates working hours of 2 times. working hours follow monday-friday 9am 6pm saturday 9am 1pm sunday off
two columns created
, closed
. if created date of saturday should calculate created time till 1pm + (closed-9am) of monday.sunday should 0. how achieve that??
$ select `id` 'no', `subject`, `status`, `created`, `closed`, case when (date(ot.`created`) = date(ot.`closed`)) concat( '0 days ', floor(hour(timediff(`closed`, `created`))),' hours ', (case when minute(timediff(`closed`, `created`)) < 10 concat( minute(timediff(`closed`, `created`)), ' minutes') else concat(((floor(minute(`created`)/10)) +1), '0 minutes')end)) when (date(date_add(ot.`created`, interval 1 day)) = date(ot.`closed`)) case when hour(`created`)>'18' concat( floor(((hour(`closed`)-9) )/9),' days ', mod(( (hour(`closed`)-9) ), 9), ' hours ', ((floor(minute(`created`)/10)) +1), '0 minutes' ) else concat( floor(( (18-hour(`created`)) + (hour(`closed`)-9) )/9),' days ', mod(( (18-hour(`created`)) + (hour(`closed`)-9) ), 9), ' hours ', ((floor(minute(`created`)/10)) +1),'0 minutes' ) end when (date(ot.`created`) <= date(date_add(ot.`closed`, interval 1 day))) concat( floor(( (18-hour(`created`)) + ((datediff( `closed`, `created`)-1)*9) + (hour(`closed`)-9) )/9),' days ',mod(( (18-hour(`created`)) + ((datediff( `closed`, `created`)-1)*9) + (hour(`closed`)-9) ), 9), ' hours ', ((floor(minute(`created`)/10)) +1),'0 minutes' ) end tat, myoffice ot inner join ot.`status`='closed' , month(`created`)='10' order tat desc %$
Comments
Post a Comment