1. 查看month 相关的函数
hive (felix)> show functions like '*date*';
OK
tab_name
current_date
date_add
date_format
date_sub
datediff
to_date
Time taken: 0.017 seconds, Fetched: 6 row(s)
2.查看 add_months 函数的用法
hive (felix)> desc function datediff;
OK
tab_name
datediff(date1, date2) - Returns the number of days between date1 and date2
Time taken: 0.014 seconds, Fetched: 1 row(s)
hive (felix)>
3. 查看 add_months 函数的详细说明并举例
hive (felix)> desc function extended datediff;
OK
tab_name
datediff(date1, date2) - Returns the number of days between date1 and date2
date1 and date2 are strings in the format 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'. The time parts are ignored.If date1 is earlier than date2, the result is negative.
Example:
> SELECT datediff('2009-07-30', '2009-07-31') FROM src LIMIT 1;
1
Function class:org.apache.hadoop.hive.ql.udf.generic.GenericUDFDateDiff
Function type:BUILTIN
Time taken: 0.011 seconds, Fetched: 7 row(s)
hive (felix)>