select T21620.日期 as F21634, QUARTER('98-04-01') as quarter #返回日期是一年的第几个季度 -> 2 ,'98-04-01' or '1998-04-01' or '19980401' 都可以,但是只有年月没有日会报错,如'199804' from 竟企数据分析 T21620 说明:T21620.日期是201501这种格式,需要后边都加上日01 quarter才能识
可以用pg自带函数select extract(dow from current_date),之所以没用主要是展示一下通过数学方法计算日期的原理. drop function if exists getDateWeek(date);drop function if exists intervalDay(date);drop function if exists getMonMaxDay(integer,integer);drop function if exists getMonMaxDate(
Mysql 按年.季度.月分组 按月度分组: select DATE_FORMAT(i.created_at, '%Y-%m月')...................GROUP BY DATE_FORMAT(i.created_at, '%Y-%m') 按季度分组: select CONCAT(YEAR(i.created_at),'_',QUARTER(i.created_at),'Q')....................GROUP BY CONCAT(YEAR(i.created_