background
The type of TRANSTAMP3 and TRANSTAMP2 in the Oracle database is varchar, but the actual saved value is the timestamp type. Now we need to calculate the millisecond difference between the two.
Oracle或MySQL
extract(second from (to_timestamp(TRANSTAMP3,'yyyy-mm-dd hh24:mi:ss.ff') - to_timestamp(TRANSTAMP2,'yyyy-mm-dd hh24:mi:ss.ff'))) * 1000
ODPS
The data warehouse uses ODPS to store data and cannot recognize the extract function. The sql is as follows:
DATEDIFF(to_date(TRANSTAMP3,'yyyy-MM-dd hh:mi:ss.ff3'),to_date(TRANSTAMP2,'yyyy-MM-dd hh:mi:ss.ff3'),'ff3')