MySQL MAKETIME is one of the Date Functions, which is useful to calculate or get time from the hour, minute, and second arguments given by us.
This article shows you how to use this Make time to get or calculate time with an example. The basic syntax of the MySQL Maketime Function is as shown below:
MAKETIME(hour, minutes, seconds);
MySQL Maketime function Example
These examples help you understand the use of this method. 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);
Let us see another example of the 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()));
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 method statement, we used the HOUR, MINUTE, and SECOND functions inside this MAKETIME. This might help you to understand how we can use other date methods inside this method.