SQL ADDTIME function
Adds a time span to a datetime or another time, returning the same type it was given.
- Catégorie
- Dates & times
- Returns
datetime / time- In this category
- 73 of 121
Syntaxe
ADDTIME(dt, time_value)
Prise en charge des moteurs
| Moteur | Support | Notes |
|---|---|---|
| SQL Server | Different name or syntax | DATEADD(SECOND, ..., d) with the parts split out |
| PostgreSQL | Different name or syntax | dt + INTERVAL '2 hours 30 minutes' |
| MySQL | Oui | Supported under this name. |
| SQLite | Different name or syntax | datetime(d, '+2 hours', '+30 minutes') |
| Oracle | Different name or syntax | dt + INTERVAL '2:30' HOUR TO MINUTE |
Exemples
MySQL
SELECT ADDTIME('2026-08-01 23:30:00', '02:30:00'); -- 2026-08-02 02:00:00
PostgreSQL
SELECT '2026-08-01 23:30:00'::timestamp + INTERVAL '2:30';
Bon à savoir
- The span is a TIME value and may include a day part: ADDTIME(d, '1 02:30:00') adds 26.5 hours. Months and years are out of reach; use DATE_ADD with INTERVAL for those.
- A TIME first argument gives a TIME result that does not wrap at midnight: ADDTIME('23:30:00', '02:30:00') is 26:00:00. Pass a datetime when you want the date to roll over.
- PostgreSQL's + interval and Oracle's interval types also cover months and years, which a TIME span cannot express.
Questions about ADDTIME
How do I add 90 minutes in MySQL?
ADDTIME(d, '01:30:00') or DATE_ADD(d, INTERVAL 90 MINUTE); the INTERVAL form reads better and scales past a day.
Why did my time go past 24:00?
MySQL's TIME doubles as a duration type and runs to 838:59:59, so ADDTIME on a TIME keeps counting past midnight. Add to a datetime if you want the day to roll over instead.
Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.
Related on SQLly
Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, SQLite, Oracle.
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.