date_part to datediff:
Green Plum:
select
(
date_part ('second' :: text, t2.transaction_date - t1.transaction_date)
) / (60 * 24 * 60) :: double precision as GP_time
from Table_T1 where t1.tra_id=t2.tran_id
Redshift:
select
DATEDIFF
(
'second', t1.transaction_date::timestamp, t2.transaction_date::timestamp
)/ (60 * 24 * 60) :: double precision as RS_time
from Table_T1 where t1.tra_id=t2.tran_id
Attention:
Pay attention to the removal of minus sign while using DATADIFF
function for Redshift, order of date column such as 2nd column will be
at 1st position and vice versa, number of argument is 3 - second /
minute / hour / day, date1, date2. Green Plum date_part function has 2
argument compared to Redshift DATEDIFF function.
Comments
Post a Comment