Hive列出两个时间中的时间列表


select tmp.*,
       case
         when pos = 0 and date_add(start_date, pos) < start_date then
          date_format(start_date, 'yyyy-MM-dd HH:mm:ss')
         else
          concat(date_format(date_add(start_date, pos), 'yyyy-MM-dd'),
                 ' 00:00:00')
       end as mid_start_date,
       
       case
         when pos = datediff(end_date, start_date) and
              date_add(start_date, pos + 1) > end_date then
          date_format(end_date, 'yyyy-MM-dd HH:mm:ss')
         else
          concat(date_format(date_add(start_date, pos + 1), 'yyyy-MM-dd'),
                 ' 00:00:00')
       end as mid_end_date
  from (select work_start_time as start_date, work_end_time as end_date
        
          from bst_bas_driver_info_work_time
         where id in ('2440780')) tmp lateral view posexplode(split(space(datediff(end_date, start_date)), '')) t as pos,
       val;

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM