请选择 进入手机版 | 继续访问电脑版

JeeGit 官方论坛

找回密码
立即注册
搜索
热搜: 活动 交友 discuz
发新帖

1

收听

0

听众

181

主题
发表于 2023-4-12 11:37:41 | 查看: 508| 回复: 0
https://blog.csdn.net/weixin_46099269/article/details/113125569


MySQL 日期加减

select adddate(now(),1); -- 加1天

select adddate(now(), interval 1 day); -- 加1天

select adddate(now(), interval 1 hour); --加1小时

select adddate(now(), interval 1 minute); -- 加1分钟

select adddate(now(), interval 1 second); -- 加1秒

select adddate(now(), interval 1 microsecond); -- 加1毫秒

select adddate(now(), interval 1 week); -- 加1周

select adddate(now(), interval 1 month); -- 加1月

select adddate(now(), interval 1 quarter); -- 加1季

select adddate(now(), interval 1 year); -- 加1年
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
postgreSQL日期加减

SELECT now()::timestamp + '1 year';  --当前时间加1年

SELECT now()::timestamp + '1 month';  --当前时间加一个月

SELECT now()::timestamp + '1 day';  --当前时间加一天

SELECT now()::timestamp + '1 hour';  --当前时间加一个小时

SELECT now()::timestamp + '1 min';  --当前时间加一分钟

SELECT now()::timestamp + '1 sec';  --加一秒钟

select now()::timestamp + '1 year 1 month 1 day 1 hour 1 min 1 sec';  --加1年1月1天1时1分1秒

SELECT now()::timestamp + (col || ' day')::interval FROM table --把col字段转换成天 然后相加
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
文章知识点与官方知识档案匹配,可进一步学习相关知识
您需要登录后才可以回帖 登录 | 立即注册

QQ|Archiver|手机版|小黑屋|JeeGit 官方论坛 ( 吉ICP备19001578号-2|吉B2-20200006 )

GMT+8, 2024-3-28 18:31 , Processed in 0.032979 second(s), 17 queries .

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表