Hive常用日期函数,时间函数
SELECT add_months('2023-07-05', -2);
SELECT add_months('2023-07-05', 2);
SELECT current_date();
SELECT current_timestamp();
SELECT datediff('2023-07-05', '2023-07-10');
SELECT datediff('2023-07-05', '2023-06-05');
SELECT date_add('2023-07-05', 8);
SELECT date_add('2023-07-05', -8);
SELECT date_format(current_date(), 'yyyy-MM');
SELECT date_format(current_timestamp(), 'yyyy-MM-dd');
SELECT date_format('2023-07-05 11:17:56.314', 'yyyy');
SELECT date_sub('2023-07-05', -2);
SELECT date_sub('2023-07-05', 2);
SELECT day('2023-07-05 11:17:56.314');
SELECT day('2023-07-05');
SELECT dayofmonth('2023-07-05 11:17:56.314');
SELECT dayofmonth('2023-07-05');
SELECT from_unixtime(1688538070,'yyyy-MM-dd');
SELECT from_unixtime(1688538070,'yyyy-MM-dd HH:mm:ss');
SELECT from_utc_timestamp('2023-07-05 11:17:56.314','PST');
SELECT from_utc_timestamp('2023-07-05 11:17:56.314','GMT');
SELECT from_utc_timestamp('2023-07-05 11:17:56.314','UTC');
SELECT from_utc_timestamp('2023-07-05 11:17:56.314','DST');
SELECT from_utc_timestamp('2023-07-05 11:17:56.314','CST');
SELECT hour('2023-07-05 11:17:56.314');
SELECT last_day('2023-07-05 11:17:56.314');
SELECT last_day('2023-07-05');
SELECT minute('2023-07-05 11:17:56');
SELECT month('2023-07-05 11:17:56');
SELECT months_between('2023-07-05','2023-06-05') ;
SELECT months_between('2023-07-05','2023-06-21') ;
SELECT next_day('2023-07-05', 'Mon');
SELECT next_day('2023-07-05', 'Tu');
SELECT next_day('2023-07-05', 'Wed');
SELECT next_day('2023-07-05', 'Th');
SELECT next_day('2023-07-05', 'Fri');
SELECT next_day('2023-07-05', 'Sat');
SELECT next_day('2023-07-05', 'Sun');
SELECT quarter('2023-07-05') ;
SELECT second('2023-07-05 11:17:56.314') ;
SELECT to_date('2023-07-05 11:17:56.314') ;
SELECT to_date('2023-07-05') ;
SELECT to_utc_timestamp('2023-07-05 11:17:56.314','GMT') ;
SELECT to_utc_timestamp('2023-07-05 11:17:56.314','PST') ;
SELECT trunc('2023-07-05 11:17:56','YY') ;
SELECT trunc('2023-07-05 11:17:56','YYYY') ;
SELECT trunc('2023-07-05 11:17:56','YEAR') ;
SELECT trunc('2023-07-05 11:17:56','MM') ;
SELECT trunc('2023-07-05 11:17:56','MON') ;
SELECT trunc('2023-07-05 11:17:56','MONTH') ;
SELECT unix_timestamp() ;
SELECT unix_timestamp('2023-07-05','yyyy-MM-dd') ;
SELECT unix_timestamp('2023-07-05 11:17:56','yyyy-MM-dd hh:mm:ss') ;
SELECT unix_timestamp('2023-07-05 11:17:56','yyyy-MM-dd HH:mm:ss') ;
SELECT weekofyear('2023-01-01') ;
SELECT weekofyear('2023-01-02') ;
SELECT weekofyear('2023-07-05') ;
SELECT weekofyear('2023-07-05 11:17:56') ;
SELECT year('2023-07-05') ;
SELECT extract(second from '2023-07-05 11:17:56') ;
SELECT extract(minute from '2023-07-05 11:17:56') ;
SELECT extract(hour from '2023-07-05 11:17:56') ;
SELECT extract(day from '2023-07-05 11:17:56') ;
SELECT extract(month from '2023-07-05 11:17:56') ;
SELECT extract(year from '2023-07-05 11:17:56') ;
SELECT extract(week from '2023-07-05 11:17:56') ;
SELECT extract(quarter from '2023-07-05 11:17:56') ;
SELECT extract(dayofweek from '2023-07-05 11:17:56') ;
end