mysql - How to roll over time past 24:00 -
mysql - How to roll over time past 24:00 -
i want @ add together 12 hrs time 430pm(16:30) when so, instead of going 04:30 going 28:30 how roll on 00:00 , 04:30.
select addtime('16:00:00', '12:00:00');
you can add together random date time i.e 2014-01-01 16:30:00
, utilize combination of addtime , date_format function. first step adding 12 hours 2014-01-01 16:30:00
below
select addtime('2014-01-01 16:30:00', '0 12:0:0');
the result of above syntax 2014-01-02 04:30:00
, need take time part of result
select date_format('2014-01-02 04:30:00', '%h:%i:%s');
so 04:30:00
expected.
below combined syntax of above produces same result
select date_format(addtime('2014-01-01 16:30:00', '0 12:0:0'), '%h:%i:%s');
sql fiddle demo
mysql time
Comments
Post a Comment