可以用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_
#include <stdio.h> #include <stdlib.h> int day_diff(int year_start, int month_start, int day_start , int year_end, int month_end, int day_end) { int y2, m2, d2; int y1, m1, d1; m1 = (month_start + 9) % 12; y1 = year_start - m1/10; d1
首先,hive本身有一个UDF,名字是datediff.我们来看一下这个日期差计算的官方描述,(下面这个是怎么出来的): hive> desc function extended datediff; OK datediff(date1, date2) - Returns the number of days between date1 and date2 date1 and date2 are strings in the format 'yyyy-MM-dd HH:mm:ss' or 'yyy
<script type="text/javascript"> getMonthBetween("2015-05-01","2016-05-01") function getMonthBetween(start,end){ var d1 = new Date(start); var d2 = new Date(end); var month1 = d1.getMonth() + 1,month2 = d2.getMonth() + 1