当前位置:网站首页>postgresql 日期处理函数用法
postgresql 日期处理函数用法
2022-07-24 05:31:00 【hsg77】
postgresql 日期处理函数用法
select now(); --当前时间 2021-04-21 11:36:56
SELECT EXTRACT (year FROM now()); --年 2021
SELECT EXTRACT (quarter FROM now()); --季 02
SELECT EXTRACT (month FROM now()); --月 04
SELECT EXTRACT (day FROM now()); --月中天 21
SELECT EXTRACT (week FROM now()); --周 16
SELECT EXTRACT (isodow FROM now()); --周中天 3
SELECT EXTRACT (hour FROM now()); --時 11
SELECT EXTRACT (minute FROM now()); --分 36
SELECT EXTRACT (second FROM now()); --秒 56.909161
获取年份:extract(year from 日期)
获取月份:extract(month from 日期)
获取季度:extract(quarter from 日期)
select
months 月份,max(最高气温)最高温, min(最低气温)最低温, max(温差) 温差
from (
select (extract(year from 日期)||'-'||extract(month from 日期)) as months, 最高气温, 最低气温, 最高气温-最低气温 温差
from weather
where extract(year from 日期) = '2018'
) a group by a.months order by months
postgresql 测试数据 别名要加as
mysql 要跟from dual
postgresql 则不跟dual
select 2 as id,'技术' as name, 2000 as value, '' as parent
union
select 1 as id,'销售' as name, 5000 as value, '' as parent
union
select 3 as id,'电话销售' as name, 2000 as value, '1' as parent
union
select 4 as id,'门店销售' as name, 3000 as value, '1' as parent
union
select 5 as id,'促销' as name, 2000 as value, '4' as parent
select
'武侯区' as name, 123 as value
union
select
'青羊区' as name, 223 as value
union
select
'金牛区' as name, 453 as value
union
select
'双流区' as name, 423 as value
union
select
'新都区' as name, 163 as value
union
select
'郫都区' as name, 193 as value
union
select
'温江区' as name, 343 as value
union
select
'青白江区' as name, 443 as value
union
select
'锦江区' as name, 403 as value
union
select
'成华区' as name, 553 as value
union
select
'双流区' as name, 553 as value
union
select
'成都市' as name, 489 as value
union
select
'四川省' as name, 500 as value
union
select
'广东省' as name, 200 as value
union
select
'新疆维吾尔自治区' as name, 1000 as value
union
select
'青海省' as name, 900 as value
union
select
'西藏自治区' as name, 900 as value
—the—end—
边栏推荐
猜你喜欢

DNS域名解析服务

Account and authority management
![[lvgl (2)]](/img/f8/d04183cf74896295382765a9dfd88d.png)
[lvgl (2)]

Special effects - when the mouse moves, there will be a custom expression trail

Flex layout

【微信小程序】一文搞懂条件渲染、列表渲染以及wxss模板样式

基于回归分析的广告投入销售额预测——K邻近,决策树,随机森林,线性回归,岭回归

【ESP8266点焊机】基于 ESP8266 for Arduino

Special effects - click with the mouse and the fireworks will burst
![[audio decoding chip] Application of vs1503 audio decoding chip](/img/ee/0d5f95fba647592cc95f1e9f410bc9.png)
[audio decoding chip] Application of vs1503 audio decoding chip
随机推荐
OpenSSL version upgrade
kubernetes简介(kubernetes优点)
Random forest, lgbm parameter adjustment based on Bayesian Optimization
【ESP8266点焊机】基于 ESP8266 for Arduino
mysql获取自增行标(区别mysql版本)
Common commands and package management of go language
深度优先搜索(模板使用)
磁盘管理和文件系统
Special effects - click the mouse and the randomly set text will appear
MySQL Index & execution plan
RAID configuration experiment
Sort by an attribute value of an object in the array
HashSet转数组
Machine learning case: smoking in pregnant women and fetal health
Special effects - bubble tailing occurs when the mouse moves
【LVGL(重要)】样式属性API函数及其参数
Combination of grep and regular
kubernetes简介和架构及其原理
DHCP原理与配置
基于回归分析的广告投入销售额预测——K邻近,决策树,随机森林,线性回归,岭回归