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 ...
随机推荐
- airflow的web任务管理
ariflow里绿的代表都跑完了:红的表示有问题:点红的图标进去: 点tree view 红色表示那一天失败: 点进去看可以看log: 点clear则是重跑任务:
- 2019牛客暑期多校训练营(第六场)-D Move
题目链接:https://ac.nowcoder.com/acm/contest/886/D 题意:给n个物品,每个物品有一个体积值,K个箱子,问箱子的最小体积为多少可将物品全部装下. 思路:比赛时一 ...
- vi去掉^M
Windows下编辑的文本文件or程序文件,拷贝到linux下,用vi打开时,有时候会看到每行末尾有个 ^M 的符号. 这里介绍一个可以快速去除^M符号的方法: 用vi编辑器打开该文件,然后输入: : ...
- VMware HorizonView虚拟化桌面TLS问题处理
问题描述 公司虚拟化桌面环境内,进出口事业部同事在使用"中国贸易单一窗口"登录系统时,其系统本地控件无法启动WSS服务,端口显示使用61231,并反复提示安装控件. 排查过程 首先 ...
- spring boot 使用elasticsearch
在文章开始之前我们先来介绍一下elasticsearch 是一个分布式的 RESTful 风格的搜索和数据分析引擎. 查询 : Elasticsearch 允许执行和合并多种类型的搜索 — 结构化.非 ...
- Hadoop集群搭建-02安装配置Zookeeper
Hadoop集群搭建-05安装配置YARN Hadoop集群搭建-04安装配置HDFS Hadoop集群搭建-03编译安装hadoop Hadoop集群搭建-02安装配置Zookeeper Hado ...
- spring-boot 使用jdk6(三)
环境 jdk 6 tomcat 7.0.59 sts 4.4.2 maven 3.2.5 背景 由于环境限制,还在使用 JDK6,所以需要将 spring boot 进行配置,支持JDK6. 以下所有 ...
- Android Application的基本组件介绍
一个Android应用通常由一个或多个基本组件组成,常用的一般有Activity.Service.BroadcastReceiver.ContentProvider.Intent等等. ⒈Activi ...
- dij 费用流
#include <bits/stdc++.h> using namespace std; typedef long long lld; const int MAXN = 50010, M ...
- maraidb忘记数据密码
一.概述 服务器上安装了maraidb 数据库,但是很久未使用过它,需要使用时,忘记了密码, 此时可以给它重新设置密码. 二.操作 修改密码 修改 /etc/my.cnf,修改下图红色区域位置,修改成 ...