The MAKETIME() function in MySQL is used to create a time value based on the given hour, minute, and second. It returns a time in the format HH:MM:SS.
Syntax:
MAKETIME(hour, minute, second)
- hour: The hour component of the time (0 to 23).
- minute: The minute component of the time (0 to 59).
- second: The second component of the time (0 to 59).
Example Usage:
-
Basic Example:
SELECT MAKETIME(12, 30, 45);Result:
'12:30:45' -
Using in a Table Query:
SELECT MAKETIME(hour_column, minute_column, second_column) FROM time_table;
Notes:
- If any of the values for hour, minute, or second are outside the valid range, MySQL adjusts them (e.g., if seconds exceed 59, it will increase the minutes accordingly).
- If any of the arguments are
NULL, the result will beNULL.
No comments:
Post a Comment