1.确定两个日期之间的工作日天数 --确定两个日期之间的工作日天数with x0 as (select to_date('2018-01-01','yyyy-mm-dd') as 日期 from dual union all select to_date('2018-01-15','yyyy-mm-dd') as 日期 from dual ), x1 as --日期并列显示 (select min (日期) 开始日期,max(日期) 结束日期 from x0 ), x2 as --日期之间的天数
首先,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
使用sql语句查询日期在一周内的数据 select * from ShopOrder where datediff(week,ordTime,getdate()-1)=0 //查询当天日期在一周年的数据 select * from ShopOrder where datediff(day,ordTime,getdate()-1)=0 //查询当天的所有数据 SELECT * FROM A where datediff(d,datetime,getdate()) <=30 //前30天 S