Reputation: 29445
I want to store a time value in a mysql table,
1345:55
it is 1345 hours and 55 minutes. What type should column have?
And if I want to pass a time variable from python to this column using mysqldb
module, which time type should i use in python? datetime.timedelta
?
Upvotes: 1
Views: 2069
Reputation: 125865
Generally speaking, one can use MySQL's TIME
datatype to store time values:
MySQL retrieves and displays
TIME
values in'HH:MM:SS'
format (or'HHH:MM:SS'
format for large hours values).TIME
values may range from'-838:59:59'
to'838:59:59'
.
Obviously, in your case, this is insufficient for the range of values required. I would therefore suggest that you instead convert the value to an integer number of minutes and store the result in an 4-byte INT UNSIGNED
column (capable of storing values in the range 0 to 4294967295, representing 0:00 to 71582788:15).
Upvotes: 1