【Oracle】求两Timestamp字段间的时间差(单位:秒)
核心语句:
select to_number(substr((update_time-create_time)*86400,2,9)) from emp610;
执行效果:
SQL> select to_number(substr((update_time-create_time)*86400,2,9)) from emp610; TO_NUMBER(SUBSTR((UPDATE_TIME-CREATE_TIME)*86400,2,9)) ------------------------------------------------------ 19
建表:
create table emp610( create_time timestamp, update_time timestamp);
充值:
insert into emp610(create_time,update_time) values(to_date('2022.06.10 18:42:40','yyyy.MM.dd hh24:mi:ss'),to_date('2022.06.10 18:42:59','yyyy.MM.dd hh24:mi:ss'))
END