MySQL Tutorial MySQL Advanced MySQL Database Account Management MySQL References


The MySQL MAKETIME() function returns a time based on specified hour, minute and second values. A time value (returned value) can range from '-838:59:59' to '838:59:59'.


MAKETIME(hour, minute, second)


hour Required. Specify the hour value used to create the time.
minute Required. Specify the minute value used to create the time.
second Required. Specify the second value used to create the time.

Return Value

Returns the time based on specified year and number_of_days values.

Example 1:

The example below shows the usage of MAKETIME() function.

mysql> SELECT MAKETIME(10, 25, 55);
Result: '10:25:55'

mysql> SELECT MAKETIME(10, 25, 0);
Result: '10:25:00'

mysql> SELECT MAKETIME(10, 0, 0);
Result: '10:00:00'

mysql> SELECT MAKETIME(23, 48, 58);
Result: '23:48:58'

mysql> SELECT MAKETIME(838, 59, 59);
Result: '838:59:59'

mysql> SELECT MAKETIME(-838, 59, 59);
Result: '-838:59:59'

Example 2:

Consider a database table called Sample with the following records:

Data 155010
Data 264020
Data 373030
Data 482040
Data 591050

To create a time based on values of column Hour, column Minute and column Second, the following query can be used:

SELECT *, MAKETIME(Hour, Minute, Second) AS MAKETIME_Value FROM Sample;

This will produce the result as shown below:

Data 1550105:50:10
Data 2640206:40:20
Data 3730307:30:30
Data 4820408:20:40
Data 5910509:10:50

❮ MySQL Functions