zoukankan      html  css  js  c++  java
  • hive中时间-日期函数的用法

    current_date:获取当前日期

    用法:select current_date;

    输出:2020-12-04

    unix_timestamp:获取当前unix时间戳

    用法:select unix_timestamp;

    输出:1607070544

    date_add:返回日期的后n天的日期

    例:返回当前时间和当前时间的后10天的时间

    用法:select current_date,date_add((select current_date),10);

    输出:2020-12-04    2020-12-14

    date_sub:返回当前时间的前n天的日期

    例:获取当前时间的前10天的日期

    用法:select date_sub((select current_date),10);

    输出:2020-11-24

    weekofyear:返回日期在本年所在的周数

    例:获取2021-01-20是2021年第几周

    用法:select weekofyear('2020-01-20');

    输出:3

    datediff(string enddate,string begindate):返回的是begindate和enddate相差的天数

    例:2020-10-09和2020-10-29相差几天?

    用法:select datediff('2020-10-29','2020-10-09');

    输出:20

  • 相关阅读:
    Math app 2.0
    “口袋精灵”单元测试
    学习进度条
    本学期总结
    sprint2的总结及团队贡献分
    点餐系统Sprint1总结
    实验8
    实验7
    实验6
    实验五
  • 原文地址:https://www.cnblogs.com/sycl/p/14087663.html
Copyright © 2011-2022 走看看