Summary: in this tutorial, you will learn how to use the MySQL MAKETIME()
function to create a time based on hour, minute, and second.
Introduction to MySQL MAKETIME() function
The MAKETIME()
function allows you to create a time value by specifying the hour, minute, and second components.
Here’s the syntax of the MAKETIME()
function:
MAKETIME(hour,minute,second)
Code language: SQL (Structured Query Language) (sql)
In this syntax:
hour
: The hour component of the time, which is an integer value between 0 and 23.minute
: The minute component of the time, which is an integer value between 0 and 59.second
: The second component of the time, which can have a fractional part, so it allows specifying fractions of a second.
MySQL MAKETIME() function example
The following example uses the MAKETIME()
function to create a time value for 12:15:30
(12 hours, 15 minutes, and 30 seconds):
SELECT MAKETIME(12, 15, 30);
Code language: SQL (Structured Query Language) (sql)
Output:
+----------------------+
| MAKETIME(12, 15, 30) |
+----------------------+
| 12:15:30 |
+----------------------+
1 row in set (0.00 sec)
Code language: SQL (Structured Query Language) (sql)
Summary
- Use the
MAKETIME()
function to create a time based on hour, minute, and second.
Was this tutorial helpful?