MySQL MAKETIME Function

MySQL MAKETIME function is one of the MySQL Date Functions, which is useful to calculate or get time from the hour, minute, second arguments given by us.

In this article, we show you how to use this MySQL Make time function to get or calculate time with an example. The basic syntax of the Maketime() Function in MySQL is as shown below:

MAKETIME(hour, minutes, seconds);

MySQL Maketime function Example

These examples help you understand the use of this MySQL Maketime function. Here, we are trying to get or calculate the time based on the hours, minutes, and seconds of three different values.

SELECT MAKETIME(11, 10, 25);

SELECT MAKETIME(12, 45, 55);

SELECT MAKETIME(23, 45, 59);
MySQL MAKETIME Function 1

Let us see another example of MySQL Maketime function. Here, we are trying to calculate the time from invalid MySQL argument values.

SELECT MAKETIME(23, 45, 75);

SELECT MAKETIME(23, 77, 59);

SELECT MAKETIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW()));
MySQL MAKETIME Function 2

From the above screenshot, the first two statements got 75 seconds (60 is Max) and 77 minutes. That’s why NULL has returned. Within the last Date Function statement, we used HOUR, MINUTE, and SECOND function inside this MAKETIME function. This might helps you to understand how we can use other date functions inside this function.