当前位置:网站首页>mysql和pgsql时间相关操作
mysql和pgsql时间相关操作
2022-04-23 06:04:00 【旺财2】
mysql时间操作
获取当前时间
select now();
2022-01-15 15:31:34.0
获取当前时间的前1天时间
select DATE_SUB(CURRENT_TIMESTAMP,INTERVAL 1 day);
可选值如下:

字符串转date
select str_to_date(DATE_SUB(now(),INTERVAL 0 day),'%Y-%m-%d %H:%i:%s');
时间格式化
select date_format(now(),'%Y-%m-%d %H:%i:%s');
pgsql时间操作
获取当前时间
select now();
2022-01-15 15:44:19.619571
获取当前时间的前1天时间
select now() - interval '1 day'
可选值如下:
时间格式化
select to_timestamp(now(),'yyyy-mm-dd hh24:mi:ss') - interval '1 day'
字符串转时间
to_timestamp('2022-01-22 00:00:00','yyyy-MM-dd hh24:mi:ss')
获取年月日时分秒
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())
字符串截取
select substr(to_timestamp(now(),'yyyy-mm-dd hh24:mi:ss'),1,19)
版权声明
本文为[旺财2]所创,转载请带上原文链接,感谢
https://blog.csdn.net/wdyliuxingfeiyang/article/details/122510998
边栏推荐
猜你喜欢

Apache Atlas 编译及安装记录

Thanos Compact组件测试总结(处理历史数据)

Implementation of multi tenant read and write in Prometheus cortex

你应该知道的 JVM 基础知识

qs.stringify 接口里把入参转为&连接的字符串(配合application/x-www-form-urlencoded请求头)

Basic concepts of database: OLTP / OLAP / HTAP, RPO / RTO, MPP

Prometheus cortex Architecture Overview (horizontally scalable, highly available, multi tenant, long-term storage)

Relabel of Prometheus_ Configs and metric_ relabel_ Configs explanation and usage examples

Prometheus thanos Quick Guide

Problems related to Prometheus cortex using block storage
随机推荐
Dolphinscheduler调度sql任务建表时The query did not generate a result set异常解决
Prometheus监控influxdb的方法及指标释义
冬季实战营 动手实战-初识上云基础,动手实操ECS云服务器新手上路 领鼠标 云小宝 背包 无影
基于EMR离线数据分析-反馈有礼
Prometheus Thanos快速指南
阿里矢量库的图标使用教程(在线,下载)
基于ECS搭建云上博客(云小宝码上送祝福,免费抽iphone13任务详解)
异常记录-9
Thanos Compactor组件使用
异常记录-22
BCC installation and basic tool instructions
OSS云存储管理实践(体验有礼)
19C中ASM network未自动启动的处理
VirtualBox如何修改“网络地址转换(NAT)”网络模式下分配给虚拟机的IP网段
MySQL server standalone deployment manual
Construire un blog Cloud basé sur ECS (bénédiction sur le Code Cloud Xiaobao, explication détaillée de la tâche iphone13 gratuite)
RAC环境中openssh版本对SSH互信创建的影响
Prometheus Cortex多租户读写的实现
Build a cloud blog based on ECS (polite experience)
Using Prom label proxy to implement label based multi tenant reading of Prometheus thanos