MySQL MAKETIME() Function

 

The MAKETIME() function creates and returns a TIME value based on the specified hour, minute, and second values.


Definition and Usage

  • The function takes hour, minute, and second as input parameters and returns a TIME value in the format HH:MM:SS.

Syntax

MAKETIME(hour, minute, second)

Parameter Values

Parameter Description Requirement
hour The hour value Required
minute The minute value Required
second The second value Required

Examples

Example 1: Create a time with hour, minute, and second

SELECT MAKETIME(11, 35, 4);

Output:

11:35:04

Example 2: Create a time with specific values

SELECT MAKETIME(16, 1, 0);

Output:

16:01:00

Example 3: Time close to the boundary of the maximum value

SELECT MAKETIME(21, 59, 59);

Output:

21:59:59

Example 4: Handle large hour values

SELECT MAKETIME(838, 59, 59);

Output:

838:59:59

Technical Details

  • Works in MySQL versions: From MySQL 4.0.
  • Return Type: The function returns a TIME value in the format HH:MM:SS.

Notes:

  • MySQL supports times up to 838:59:59. Values exceeding this may not work as expected.

Was this article helpful?