MySQL MAKETIME function is a Date Function, which is used to calculate or get time from hour, minute, second arguments given by us.
In this article, we will show you, How to use this MySQL Make time function to get or calculate time with an example.
MySQL Maketime Syntax
The basic syntax of the Maketime() Function in MySQL is as shown below:
MAKETIME(hour, minutes, seconds);
MySQL Maketime function Example
These examples helps you understand the use of this MySQL Maketime function. Here, we are trying to get or calculate 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 MySQL Maketime function. Here, we are trying to calculate the time from invalid argument values.
SELECT MAKETIME(23, 45, 75);
SELECT MAKETIME(23, 77, 59);
SELECT MAKETIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW()));
From the above screenshot, first two statements got 75 seconds (60 is Max) and 77 minuets. That’s why, NULL has returned.
Within the last 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.
Thank You for Visiting Our Blog