MySQL MAKETIME() Function

In MySQL, the MAKETIME() function creates a time based on the specified hour, minute, and second to and returns it.

MAKETIME() Syntax

Here is the syntax of MySQL MAKETIME() function:

MAKETIME(hour, minute, second)

Parameters

hour
Required. Hour, ranging from -838 to 838.
minute
Required. Minutes, ranging from 0 to 59.
second
Required. Seconds, ranging from 0 to 59.

Return value

The MySQL MAKETIME() function creates a time based on the specified hour, minute, and second to and returns it.

  • If is minute not between 0 to 59, the MAKETIME() function will return NULL.
  • If is second not between 0 to 59, the MAKETIME() function will return NULL.

Note: MySQL supports the time range from -838:59:59to 838:59:59.

MAKETIME() Examples

Here are some examples of the MAKETIME() function.

SELECT
    MAKETIME(10, 11, 12),
    MAKETIME(100, 11, 12),
    MAKETIME(839, 11, 12),
    MAKETIME(-999, 11, 12),
    MAKETIME(10, 11, 12),
    MAKETIME(10, 60, 12),
    MAKETIME(10, 11, 75)\G
  MAKETIME(10, 11, 12): 10:11:12
 MAKETIME(100, 11, 12): 100:11:12
 MAKETIME(839, 11, 12): 838:59:59
MAKETIME(-999, 11, 12): -838:59:59
  MAKETIME(10, 11, 12): 10:11:12
  MAKETIME(10, 60, 12): NULL
  MAKETIME(10, 11, 75): NULL