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:
Data | Hour | Minute | Second |
---|---|---|---|
Data 1 | 5 | 50 | 10 |
Data 2 | 6 | 40 | 20 |
Data 3 | 7 | 30 | 30 |
Data 4 | 8 | 20 | 40 |
Data 5 | 9 | 10 | 50 |
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 | Hour | Minute | Second | MAKETIME_Value |
---|---|---|---|---|
Data 1 | 5 | 50 | 10 | 5:50:10 |
Data 2 | 6 | 40 | 20 | 6:40:20 |
Data 3 | 7 | 30 | 30 | 7:30:30 |
Data 4 | 8 | 20 | 40 | 8:20:40 |
Data 5 | 9 | 10 | 50 | 9:10:50 |
❮ MariaDB Functions