How to store time duration values in MySQL as TIME datatype?
1 answer
First, take a look here: http://dev.mysql.com/doc/refman/5.0/en/time.html
Be careful when assigning truncated values to the TIME column. MySQL interprets abbreviated TIME values with colons as the time of day. That is, "11:12" means "11:12: 00", not "00: 11:12". MySQL interprets truncated values without colons, assuming that the two right-most digits represent seconds (that is, as elapsed time rather than time of day). For example, you might think of "1112" and 1112 as "11:12:00" (12 minutes after 11:00), but MySQL interprets them as "00: 11:12" (11 minutes, 12 seconds). By analogy, "12" and "12" are interpreted as "00: 00: 12".
So, if you want to insert a song with duration = 05:55, just write this:
insert into songs (duration) values('0555');
+6
source to share