Oracle时间类型字段相减

直接上语句:

SELECT

"t1".DATE_CREATED,

"t1".LAST_UPDATED,

"t1".CHARGING_CAPACITY,

((to_date(to_char("t1".LAST_UPDATED,'yyyy-MM-dd HH24:mi:ss'),'yyyy-mm-dd hh24:mi:ss')

-to_date(to_char("t1".DATE_CREATED,'yyyy-MM-dd HH24:mi:ss'),'yyyy-mm-dd hh24:mi:ss'))*24*60*60*1000) as CHARGE_TIME,

"t1".CHARGE_AMOUNT,

"t1".PLATE_NUMBER,

"t1".SELF_NUMBERING,

"t1".STATUS,

"t1".DATA_STATUS,

"t1".CHARGE_PILE_INFO_ID,

"t2".LINE,

"t2".FRAME_NUMBER,

"t2".OWNER_NAME,

"t2".ENTERPRISE_CODE

FROM

ET_CHARGE_PILE_DATA_INFO "t1",

cs_rc_db.V_TRRT_VEH_INFO@cs_rc_db_link "t2"

WHERE

"t1".SELF_NUMBERING = "t2".SELF_NUMBERING

AND "t2".FUEL_TYPE='3';


敲黑板!!

一定要先to_char 然后再to_date

你可能感兴趣的:(Oracle时间类型字段相减)