본문 바로가기

SQL

[impala / oracle / presto/spark] Confusing Date SQL Statement Differences

1. impala

tx_dt between from_timestamp(date_add(to_timestamp(t1.base_dt, 'yyyyMMdd'),-3),'yyyyMMdd') and t1.base_dt2

a.nbr = cat(b.nbr as string)

select substr(to_date(months_add(now(),-1)),1,7) as base_ym

base_dt = to_date(now())

base_dt = to_date(date_add(now(),-1))

to_timestamp(tx_tmstmp,'yyyyMMddHHmmss') > date_add(now(), interval -10 minutes)

count(case when t1.base_dt = from_timestamp(last_day(months_add(to_timestamp(t1.tx_dt, 'yyyyMMdd'), 1)), 'yyyyMMdd') then t1.nbr else null end) as col1

t1.base_dt >= concat(from_timestamp(years_sub(now(),1),'yyyyMM'),'01')

t1.base_dt < concat(substr(from_timestamp(now(),'yyyyMMdd'),1,6),'01')

t1.base_dt = from_timestamp(date_sub(now(),1),'yyyyMMdd')

 

 

2. oracle

to_char(to_date(sysdate-1), 'YYYYMMDD') as base_dt

to_char(sysdate-1, 'yyyyMMdd')

to_char(to_date(nvl(t1.base_dt, '99991231')) -1, 'YYYYMMDD') as base_dt

to_number(substr(to_char(to_timestamp(t1.base_dt,'yyyymmdd') - to_timestamp(t1.tx_dt, 'yyyymmdd')),9,2))

 

 

3. spark

cast (month_between (base_ym, substr(base_dt,1,6)) as int) as m_end

nvl(avg(t1.intCol),0)

 

 

4. presto

r_time > timestamp '2021-12-23 00:00:00'

r_time between timestamp '2021-12-01 00:00:00' and timestamp '2021-12-31 23:59:59'

t1.base_dt = format_datetime(current_data - interval'1'day, 'yyyyMMdd')