常用日期函数

1.返回当前或指定时间的时间戳
select unix_timestamp();
select unix_timestamp("2020-10-28",'yyyy-MM-dd');

2.将时间戳转为日期格式
select from_unixtime(1603843200);

 3.当前日期

select current_date;

 4.当前的日期加时间

select current_timestamp;

5.抽取日期部分

to_date

6.

year:获取年
select year('2020-10-28 12:12:12');

month:获取月
select month('2020-10-28 12:12:12');

day:获取日
select day('2020-10-28 12:12:12');

hour:获取时
select hour('2020-10-28 13:12:11');

minute:获取分
select minute('2020-10-28 12:12:12');

second:获取秒
select second('2020-10-28 12:12:12');

weekofyear:当前时间是一年中的第几周
select weekofyear('2020-10-28 12:12:12');

7.weekofyear:

当前时间是一年中的第几周

8.dayofmonth:当前时间是一个月中的第几天

9.

months_between: 两个日期间的月份

datediff:两个日期相差的天数

10.date_add:日期加天数

11.last_day:日期的当月的最后一天

12.date_format(): 格式化日期

select date_format('2020-10-28 12:12:12','yyyy/MM/dd HH:mm:ss');

select date_format('2020-10-28 12:12:12','yyyy-MM-dd');

常用取整函数

round: 四舍五入
select round(3.14);
select round(3.54);

ceil: 向上取整
select ceil(3.14);
select ceil(3.54);

floor: 向下取整
select floor(3.14);
select floor(3.54);

常用字符串操作函数

upper: 转大写
select upper('low');

lower: 转小写
select lower('low');

length: 长度
select length("atguigu");

trim: 前后去空格
select trim(" atguigu ");

lpad: 向左补齐,到指定长度
select lpad('atguigu',9,'g');

rpad: 向右补齐,到指定长度
select rpad('atguigu',9,'g');

regexp_replace:使用正则表达式匹配目标字符串,匹配成功后替换!
SELECT regexp_replace('2020/10/25', '/', '-');

集合操作

size: 集合中元素的个数
select size(friends) from test3;

map_keys: 返回map中的key
select map_keys(children) from test3;

map_values: 返回map中的value
select map_values(children) from test3;

array_contains: 判断array中是否包含某个元素
select array_contains(friends,'bingbing') from test3;

sort_array: 将array中的元素排序
select sort_array(friends) from test3;

grouping sets:多维分析

最新文章

  1. CMakeLists.txt
  2. Windows Azure HDInsight 使用技巧
  3. hdu1520 Anniversary party (树形dp)
  4. POJ2676Sudoku(类似于八皇后)
  5. OUT函数及其熟练使用,split的用法
  6. strlen和mb_strlen区别
  7. ADT开发中的一些优化设置:代码背景色、代码字体大小、代码自动补全
  8. 编程的宗派(OOP与FP孰优孰劣)--王垠
  9. Singleton 单例模式 泛型 窗体控制
  10. Unity--关于优化方面的那些事儿(一)
  11. 解决log4j和self4j日志报错Could NOT find resource [logback.groovy]及Could NOT find resource [logback-test.xml]问题
  12. Ubuntu 12.04安装教程详细步骤(图解)
  13. 【sping揭秘】21、Spring动态数据源的切换
  14. Java逻辑运算
  15. zip&ftp命令
  16. JavaScript:改变 HTML 图像
  17. Intellj(IDEA)创建java webapp
  18. 【java规则引擎】《Drools7.0.0.Final规则引擎教程》第4章 4.2 agenda-group
  19. NYOJ 18 The Triangle 填表法,普通dp
  20. Google大牛分享的面试秘籍

热门文章

  1. 【LeetCode】494. Target Sum 解题报告(Python & C++)
  2. 晴天小猪历险记之Hill(Dijkstra优先队列优化)
  3. 1018 - Brush (IV)
  4. MyBatis 流式查询
  5. BBN: Bilateral-Branch Network with Cumulative Learning for Long-Tailed Visual Recognition
  6. vue安装使用v-chart时报错解决方案
  7. Java面向对象笔记 • 【第8章 内部类和泛型】
  8. 开源社区Review代码步骤
  9. nignx-防盗链
  10. 下面哪些命令可以查看file1文件的第300-500行的内容?