1. 程式人生 > >Hive和sparksql中的dayofweek

Hive和sparksql中的dayofweek

dayofweek在hive2.2.0開始支援
低版本的sparksql和hive中可用以下方式實現

 select 7- datediff(next_day('2018-03-12',"Sunday"),'2018-03-12').  
 select date_format('2018-03-12' ,'u').   
 select date_format(from_unixtime(unix_timestamp('20180313','yyyyMMdd'),'yyyy-MM-dd'),'u')