sql - Convert integer to hours mysql -
i'm storing duration decimal 0.5 half hour, 2 two hours, , on. when doing calculations times, need have represented in h:i:s, 0.5 = 00:30:00.
how should approach in mysql? application small , not public consumption, , i'm not fussed if solution hackish.
my goal able use in timeadd(my_time, duration). did miss in manual?
try query
select id, type, details, duration, sec_to_time(duration*60*60) durationintime tbl
sql fiddle:
| id | type | details | duration | durationintime | ----------------------------------------------------------------------------------- | 1 | email | admin@sqlfiddle.com | 10.5 | january, 01 1970 10:30:00+0000 | | 2 | twitter | @sqlfiddle | 5 | january, 01 1970 05:00:00+0000 | | 3 | blahblah | xyz | 5.5 | january, 01 1970 05:30:00+0000 |
hope helps
Comments
Post a Comment