Impala日付機能コンプリートセット



Impala Date Function Complete Set



Hive date function Increase month add_months(timestamp date, int months) add_months(timestamp date, bigint months) Return type: timestamp usage:add_months(now(),1) Increase date adddate(timestamp startdate, int days), adddate(timestamp startdate, bigint days) Return type: timestamp usage:adddate(now(),1) Current timestamp current_timestamp()withnow()Equivalent Date subtraction datediff(string enddate, string startdate) Return type: int usage:datediff('2018-08-05', '2018-08-03') Get the day, get the month day(string date) Return type: int usage: day('2018-08-05') Get week English dayname(string date) Return type: string usage:dayname('2018-08-05') Sunday Getting this day is the first few days of the week dayofweek(string date) 1 (Sunday) to 7 (Saturday). Return type: int usage:dayofweek('2018-08-06') Days days_add(timestamp startdate, int days) Return type: timestamp usage:days_add(now(),2) Days minus days_sub(timestamp startdate, int days) Return type: timestamp usage:days_sub(now(), 2) Formatted date from_unixtime(bigint unixtime[, string format]) Return type: string Attention parameter usage:from_unixtime(1392394861,'yyyy-MM-dd') Get hours hour(string date) Return type: int usage:hour('2018-08-06 12:32:54') Increase hours hours_add(timestamp date, int hours) Return type: timestamp usage:hours_add(now(),2) cut back hours_sub(timestamp date, int hours) Return type: timestamp usage:hours_sub(now(),2) Get minutes minute(string date) Return type: int usage:minute(now()) Increase minutes minutes_add(timestamp date, int minutes) Return type: timestamp usage:minutes_add(now(),2) Minus reduction minutes_sub(timestamp date, int minutes) Return type: timestamp usage:minutes_sub(now(),2) Get the month month(string date) Return type: int usage:month('2018-08-06 12:32:54') Adding months months_add(timestamp date, int months) Return type: timestamp usage:months_add(now(),3) Decrease month months_sub(timestamp date, int months) Return type: timestamp months_sub(now(),3) Get seconds second(string date) Return type: int Second plus seconds_add(timestamp date, int seconds) Return type: timestamp Second reduction seconds_sub(timestamp date, int seconds) Return type: timestamp Get the date to_date(now()) get1970To this second unix_timestamp(), unix_timestamp(string datetime), unix_timestamp(string datetime, string format), unix_timestamp(timestamp datetime) Return type: bigint How many weeks of the year is this week? weekofyear(string date) Return type: int usage:weekofyear('2018-08-06 12:32:54') Zhou Jia weeks_add(timestamp date, int weeks) Return type: timestamp usage:weeks_add('2018-08-06 12:32:54', 1) Week reduction weeks_sub(timestamp date, int weeks) Return type: timestamp usage:weeks_sub('2018-08-06 12:32:54', 1) Get the year year(string date) Return type: int Annual plus years_add(timestamp date, int years) Return type: timestamp Annual reduction years_sub(timestamp date, int years) Return type: timestamp