impala日期函数详解(转载)

 

 

遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/qq_22222499/article/details/81463516

 
  1. hive 日期函数

  2. 增加月份

  3. add_months(timestamp date, int months)

  4. add_months(timestamp date, bigint months)

  5. Return type: timestamp

  6. usage:add_months(now(),1)

  7. 增加日期

  8. adddate(timestamp startdate, int days),

  9. adddate(timestamp startdate, bigint days)

  10. Return type: timestamp

  11. usage:adddate(now(),1)

  12. 当前时间戳

  13. current_timestamp()和now()等价

  14. 日期相减

  15. datediff(string enddate, string startdate)

  16. Return type: int

  17. usage:datediff("2018-08-05", "2018-08-03")

  18. 得到天,得到月份

  19. day(string date)

  20. Return type: int

  21. usage: day("2018-08-05")

  22. 得到星期英文

  23. dayname(string date)

  24. Return type: string

  25. usage:dayname("2018-08-05") Sunday

  26. 得到这一天是这周的第几天

  27. dayofweek(string date) 1 (Sunday) to 7 (Saturday).

  28. Return type: int

  29. usage:dayofweek("2018-08-06")

  30. 加天数

  31. days_add(timestamp startdate, int days)

  32. Return type: timestamp

  33. usage:days_add(now(),2)

  34. 减天数

  35. days_sub(timestamp startdate, int days)

  36. Return type: timestamp

  37. usage:days_sub(now(), 2)

  38. 格式化日期

  39. from_unixtime(bigint unixtime[, string format])

  40. Return type: string

  41. 注意参数

  42. usage:from_unixtime(1392394861,"yyyy-MM-dd");

  43. 得到小时

  44. hour(string date)

  45. Return type: int

  46. usage:hour("2018-08-06 12:32:54")

  47. 增加小时

  48. hours_add(timestamp date, int hours)

  49. Return type: timestamp

  50. usage:hours_add(now(),2)

  51. 减少

  52. hours_sub(timestamp date, int hours)

  53. Return type: timestamp

  54. usage:hours_sub(now(),2)

  55. 得到分钟

  56. minute(string date)

  57. Return type: int

  58. usage:minute(now())

  59. 增加分钟

  60. minutes_add(timestamp date, int minutes)

  61. Return type: timestamp

  62. usage:minutes_add(now(),2)

  63. 减少分钟

  64. minutes_sub(timestamp date, int minutes)

  65. Return type: timestamp

  66. usage:minutes_sub(now(),2)

  67. 得到月份

  68. month(string date)

  69. Return type: int

  70. usage:month("2018-08-06 12:32:54")

  71. 月份相加

  72. months_add(timestamp date, int months)

  73. Return type: timestamp

  74. usage:months_add(now(),3)

  75. 减月份

  76. months_sub(timestamp date, int months)

  77. Return type: timestamp

  78. months_sub(now(),3)

  79. 得到秒

  80. second(string date)

  81. Return type: int

  82. 秒加

  83. seconds_add(timestamp date, int seconds)

  84. Return type: timestamp

  85. 秒减

  86. seconds_sub(timestamp date, int seconds)

  87. Return type: timestamp

  88. 得到日期

  89. to_date(now())

  90. 得到1970到今秒

  91. unix_timestamp(),

  92. unix_timestamp(string datetime),

  93. unix_timestamp(string datetime, string format),

  94. unix_timestamp(timestamp datetime)

  95. Return type: bigint

  96. 得到这周是这年的多少周

  97. weekofyear(string date)

  98. Return type: int

  99. usage:weekofyear("2018-08-06 12:32:54")

  100. 周加

  101. weeks_add(timestamp date, int weeks)

  102. Return type: timestamp

  103. usage:weeks_add("2018-08-06 12:32:54", 1)

  104. 周减

  105. weeks_sub(timestamp date, int weeks)

  106. Return type: timestamp

  107. usage:weeks_sub("2018-08-06 12:32:54", 1)

  108. 得到年

  109. year(string date)

  110. Return type: int

  111. 年加

  112. years_add(timestamp date, int years)

  113. Return type: timestamp

  114. 年减

  115. years_sub(timestamp date, int years)

  116. Return type: timestamp

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值