2023-01-29 时间类型操作.md

postgresql-时间类型操作

operator example result
+ select date '2023-01-29' + integer '1'; 2023-01-30
+ select date '2023-01-29' + interval '1 hour'; 2023-01-29 01:00:00
+ select date '2023-01-29' + time '03:00'; 2023-01-29 03:00:00
+ select interval '1 day' + interval '1 hour'; 1 day 01:00:00
+ select timestamp '2023-01-29 01:00' + interval '23 hours'; 2023-01-30 00:00:00
+ select time '01:00' + interval '3 hours'; 04:00:00
- select - interval '23 hours'; -23:00:00
- select date '2023-01-29' - date '2023-01-25'; 4
- select date '2023-01-29' - integer '7'; 2023-01-22
- select date '2023-01-29' - interval '1 hour'; 2023-01-28 23:00:00
- select time '05:00' - interval '2 hours'; 03:00:00
- select timestamp '2023-01-29 23:00:00' - interval '23 hours'; 2023-01-29 00:00:00
- select interval '1 day' - interval '1 hour'; 1 day -01:00:00
- select timestamp '2023-01-29 03:00' -timestamp '2023-01-28 12:00'; 15:00:00
* select 900 * interval '1 second'; 00:15:00
* select 21 * interval '1 day'; 21 days
* select double precision '3.5' * interval '1 hour'; 03:30:00
/ select interval '1 hour' / double precision '1.5'; 00:40:00

你可能感兴趣的:(2023-01-29 时间类型操作.md)