MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB MAKETIME() Function



The MariaDB 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'.

Syntax

MAKETIME(hour, minute, second)

Parameters

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.

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

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

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

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

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

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

Example 2:

Consider a database table called Sample with the following records:

DataHourMinuteSecond
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:

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

❮ MariaDB Functions