// dates & times reference

SQL MAKETIME function

Returns a time value from three integers, with an hour range that stretches far past 24 because MySQL's TIME doubles as a duration.

カテゴリ
Dates & times
Returns
time
In this category
27 of 121

構文

MAKETIME(hh, mm, ss)

エンジンサポート

エンジンSupportメモ
SQL Server Different name or syntax TIMEFROMPARTS(hh, mm, ss, 0, 0)
PostgreSQL Different name or syntax make_time(hh, mm, ss)
MySQL はい Supported under this name.
SQLite Different name or syntax printf('%02d:%02d:%02d', hh, mm, ss)
Oracle Not built in no direct constructor; compose a date or interval

例

MySQL

SELECT MAKETIME(9, 30, 0) AS start_time;

SQL Server

SELECT TIMEFROMPARTS(9, 30, 0, 0, 0) AS start_time;

知っておくと便利なこと

  • Minutes or seconds of 60 or more return NULL, but hours up to 838 are accepted: MAKETIME(100, 0, 0) is 100:00:00, and anything larger clamps to 838:59:59 with a warning.
  • Negative hours work too: MAKETIME(-3, 0, 0) is -03:00:00, which breaks naive parsing that assumes positive clock times.
  • Fractional seconds pass as a decimal third argument: MAKETIME(9, 30, 10.5) returns 09:30:10.5.

Questions about MAKETIME

Can MAKETIME return more than 24 hours?

Yes, up to 838:59:59. The TIME type stores durations too, so MAKETIME(100,0,0) is legal; cast or validate if you expect clock times.

What is the SQL Server equivalent?

TIMEFROMPARTS(hh, mm, ss, fraction, precision); its fifth argument declares how many fractional digits the fourth argument carries.

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, SQLite.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.