DAY_HOUR is a composite interval unit available in MySQL and MariaDB. It lets you work with the day and hour portions of a datetime value as a single numeric field. You can:1. Extract the combined value (in the form DDHH) from a DATETIME or TIMESTAMP using EXTRACT().2. Add or subtract an interval expressed in days and hours using DATE_ADD(), DATE_SUB(), or the INTERVAL keyword.Internally, MySQL stores the interval as a four-digit decimal where the first two digits are days (00-99) and the last two digits are hours (00-23). For arithmetic, MySQL converts the supplied value into the equivalent number of seconds before performing the operation.Caveats:- The hours component must be 00-23; anything higher triggers ER_WRONG_VALUE_FOR_TYPE.- Leading zeros are required when either days or hours is a single digit (e.g., '0307' means 3 days and 7 hours).- DAY_HOUR cannot be used with DATE_FORMAT(); it is only valid with EXTRACT, DATE_ADD, DATE_SUB, and TIMESTAMPDIFF.- Unsupported in PostgreSQL, SQL Server, Oracle, or SQLite.
datetime_expr DATETIME
(TIMESTAMP) - DATE|||The value to operate on.expr
(CHAR) - INT|||Four-digit literal or column containing DDHH.EXTRACT, INTERVAL, DATE_ADD, DATE_SUB, TIMESTAMPDIFF, SQL DATE
MySQL 4.1.1
It represents 3 days and 7 hours. The first two digits are days, the last two are hours.
No. DAY_HOUR only accepts whole hours (00-23). Use separate DAY and HOUR arithmetic or convert to minutes.
DAY_HOUR returns a four-digit integer. Apply MOD(value, 100) to isolate the hour component.
No. It is a MySQL extension. Other engines use different interval syntax or require two fields.