How to use TIME type in MySQL?

I am creating my first DB via MySQL Workbench. In the table, I need to store an attribute time

that contains minutes and seconds. Due to this, I wanted to use the datatype time

. What is the argument required by the type TIME(...)

?

+3


source to share


2 answers


I figured I entered TIME without parentheses. I thought TIME requires an input parameter.



CREATE TABLE IF NOT EXISTS CookingDB

. Recipe

(... CookingTime

TIME NULL,... >


+5


source


As the MYSQL docs said :

MySQL retrieves and displays TIME values ​​in "HH: MM: SS" format



You should use the TIME datatype to represent the time of day, however to store only the minutes and seconds you need use DATE_FORMAT to format your time in the correct format.

Note that the TIME data type takes up 3 bytes of space.

+1


source







All Articles