hive常用日期函数-模板
已知日期 |
要求日期 |
语句 |
结果 |
本周任意一天 |
本周一 |
select date_sub(next_day('2016-11-29','MO'),7) ; |
2016-11-28 |
本周任意一天 |
上周一 |
select date_sub(next_day('2016-11-29','MO'),14) ; |
2016-11-21 |
本周任意一天 |
本周二 |
select date_sub(next_day('2016-11-29','MO'),6) |
2016-11-29 |
本周任意一天 |
上周二 |
select date_sub(next_day('2016-11-29','MO'),13) ; |
2016-11-22 |
本周任意一天 |
上周末 |
select date_sub(next_day('2016-11-29','MO'),8) ; |
2016-11-27 |
本月任意一天 |
上月末 |
select date_sub(trunc('2016-11-02','MM'),1); |
2016-10-31 |
本月任意一天 |
上月初 |
select trunc(add_months('2016-11-02',-1),'MM') |
2016-10-01 |
本月任意一天 |
本月初 |
select trunc('2016-11-02','MM') |
2016-11-01 |
本月任意一天 |
上上月26 |
select date_add(add_months(trunc('2016-11-02','MM'),-2),25) ; |
2016-09-26 |
本月任意一天 |
上月26 |
select date_add(add_months(trunc('2016-11-02','MM'),-1),25) ; |
2016-10-26 |
当前时间戳 |
select current_timestamp() ; |
2016-11-30 15:18:06.276 |
|
当前时间 |
select current_date() ; |
2016-11-30 |
|
本季度任意一天 |
上季度初 |
case quarter('2016-05-23') when 1 then concat(year('2016-05-23')-1,'-10-01') when 2 then concat(year('2016-05-23'),'-01-01') when 3 then concat(year('2016-05-23'),'-04-01') when 4 then concat(year('2016-05-23'),'-07-01') end 或 add_months(concat(year('2017-02-23'),'-',substr(concat('0',quarter('2017-02-23')*3+1),-2),'-01'),-6) |
|
本季度任意一天 |
本季度初 |
case quarter('2016-05-23') when 1 then concat(year('2016-05-23'),'-01-01') when 2 then concat(year('2016-05-23'),'-04-01') when 3 then concat(year('2016-05-23'),'-07-01') when 4 then concat(year('2016-05-23'),'-10-01') end 或 add_months(concat(year('2017-02-23'),'-',substr(concat('0',quarter('2017-02-23')*3+1),-2),'-01'),-3) |
|
hive常用日期函数-模板的更多相关文章
- 【hive 日期函数】Hive常用日期函数整理
1.to_date:日期时间转日期函数 select to_date('2015-04-02 13:34:12');输出:2015-04-02122.from_unixtime:转化unix时间戳到当 ...
- Hive中日期函数总结
--Hive中日期函数总结: --1.时间戳函数 --日期转时间戳:从1970-01-01 00:00:00 UTC到指定时间的秒数 select unix_timestamp(); --获得当前时区 ...
- SQL常用日期函数
原文:http://www.cnblogs.com/coconut_zhang/archive/2009/02/02/1382598.html 1. 当前系统日期.时间 select getdate( ...
- Hive的日期函数
1.unix时间戳转时间函数 语法: from_unixtime(bigint unixtime[, string format]) 返回值: string 说明: 转化UNIX时间戳(从1970-0 ...
- hive时间日期函数及典型场景应用
1.hive取得当前日期时间: 1.1) 取得当前日期: select current_date(); 1.2) 取得当前日期时间: select current_timestamp(); 1.3) ...
- MySql常用日期函数(转载)
/*date_add(date,interval expr type)和date_sub(date,interval expr type)执行日期运算. date 是一个 datetime 或date ...
- Oracle常用日期函数
常用的时间格式掩码如下:掩码元素 含义YYYY 四位数年份 (如:2005) yearYY 二位数年份(如 05) Q ...
- ORACLE 常用日期函数
1 . add_months(arg1,num) 返回日期arg1加num个月的新日期. select add_months(date'2011-1-1',1) from dual; result: ...
- hiveSQL常用日期函数
注意 MM,DD,MO,TU 等要大写 Hive 可以在 where 条件中使用 case when 已知日期 要求日期 语句 结果 本周任意一天 本周一 select date_sub(next_d ...
随机推荐
- 跑跑卡丁车(dp)
题意:https://www.nitacm.com/problem_show.php?pid=1470 #define IOS ios_base::sync_with_stdio(0); cin.ti ...
- python 高阶函数 lamdad reduce map
## def use_filer(l):## # 过滤偶数# rest = filter(lambda n: n % 2 != 0, l)# return rest## if __name__ == ...
- Stardew Valley(星露谷物语)Mod开发之路 1环境配置
首先来说明一下,我写这个章节本身也是对学习过程的记录,主要参考了http://canimod.com/guides/creating-a-smapi-mod中的内容.也推荐大家看看. *这些是我的开发 ...
- Maven学习存档(1)——安装
一.安装 1.1 jdk的下载与安装 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html 版本:maven2 ...
- luogu题解 P3709 【大爷的字符串题】
题目链接: https://www.luogu.org/problemnew/show/P3709 思路: 首先我是没读懂题目的,浏览了讨论区的dalao发现才知道就是求区间众数的出现次数. 然后肯定 ...
- O061、Boot from Volume
参考https://www.cnblogs.com/CloudMan6/p/5679384.html Volume 除了可以用作Instance的数据盘,也可以作为启动盘(Bootable Vol ...
- go语言中获取变量类型的三种方法
package main import ( "fmt" "reflect" ) func main() { var num float64 = 3.14 // ...
- docker 网络模式详解
一.前言 Docker作为目前最火的轻量级容器技术,有很多令人称道的功能,如Docker的镜像管理.然而,Docker同样有着很多不完善的地方,网络方面就是Docker比较薄弱的部分.因此,我们有必要 ...
- Windows 系统自动登录配置
1. open regedit 2. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon 3.在打开的项右 ...
- Line 算法与deepwalk的对比 和个人理解
用户的关注关系本身就是一个图结构,要从用户关注关系生成用户的embedding表示,其实就是做graph的emebding表示. deepwalk+word2vec 比较简单,效果也还可以.这种方法再 ...