当前位置:网站首页>MySQL and PgSQL time related operations
MySQL and PgSQL time related operations
2022-04-23 13:41:00 【Wangcai 2】
mysql Time operation
Get the current time
select now();
2022-01-15 15:31:34.0
Before getting the current time 1 Days time
select DATE_SUB(CURRENT_TIMESTAMP,INTERVAL 1 day);
The optional values are as follows :
String rotation date
select str_to_date(DATE_SUB(now(),INTERVAL 0 day),'%Y-%m-%d %H:%i:%s');
Time format
select date_format(now(),'%Y-%m-%d %H:%i:%s');
pgsql Time operation
Get the current time
select now();
2022-01-15 15:44:19.619571
Before getting the current time 1 Days time
select now() - interval '1 day'
The optional values are as follows :
Time format
select to_timestamp(now(),'yyyy-mm-dd hh24:mi:ss') - interval '1 day'
String to time
to_timestamp('2022-01-22 00:00:00','yyyy-MM-dd hh24:mi:ss')
Gets the minutes and seconds of the year, month and day
select extract(year from now()) || extract(month from now()),extract(day from now()),extract(hour from now()),extract(minute from now()),extract(second from now())
String interception
select substr(to_timestamp(now(),'yyyy-mm-dd hh24:mi:ss'),1,19)
版权声明
本文为[Wangcai 2]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230604300404.html
边栏推荐
- Solution: you have 18 unapplied migration (s) Your project may not work properly until you apply
- QT调用外部程序
- SAP ui5 application development tutorial 72 - trial version of animation effect setting of SAP ui5 page routing
- Oracle lock table query and unlocking method
- Double pointer instrument panel reading (I)
- MySQL5. 5 installation tutorial
- Android clear app cache
- QT calling external program
- Interface idempotency problem
- Riscv MMU overview
猜你喜欢
Android clear app cache
[Video] Bayesian inference in linear regression and R language prediction of workers' wage data | data sharing
@优秀的你!CSDN高校俱乐部主席招募!
Ai21 labs | standing on the shoulders of giant frozen language models
Tangent space
Riscv MMU overview
You and the 42W bonus pool are one short of the "Changsha bank Cup" Tencent yunqi innovation competition!
【视频】线性回归中的贝叶斯推断与R语言预测工人工资数据|数据分享
Summary of request and response and their ServletContext
Opening: identification of double pointer instrument panel
随机推荐
Playwright contrôle l'ouverture de la navigation Google locale et télécharge des fichiers
Database transactions
Launcher hides app icons that do not need to be displayed
@Excellent you! CSDN College Club President Recruitment!
What do the raddr and rport in webrtc ice candidate mean?
[point cloud series] Introduction to scene recognition
[quick platoon] 215 The kth largest element in the array
Remove the status bar
面试官给我挖坑:URI中的 “//” 有什么用?
面试官给我挖坑:单台服务器并发TCP连接数到底可以有多少 ?
[andorid] realize SPI communication between kernel and app through JNI
Oracle job scheduled task usage details
浅谈js正则之test方法bug篇
innobackupex增量备份
Modification of table fields by Oracle
Playwright controls local Google browsing to open and download files
“湘见”技术沙龙 | 程序员&CSDN的进阶之路
Esp32 vhci architecture sets scan mode for traditional Bluetooth, so that the device can be searched
Lenovo Savior y9000x 2020
Explanation of input components in Chapter 16