天天看点

Oracle中,将number类型的毫秒数转换为时间格式

有些时候,我们会遇到查询出来的时间是一堆毫秒值,它表示从1970年1月1日00点00分00秒到现在的毫秒值,这时候我们需要把它转换成我们熟悉的时间格式。

首先需要创建一个这样函数

create or replace function num_to_date(in_number NUMBER) return date is  begin     return(TO_DATE('19700101','yyyymmdd')+ in_number/86400000+TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))/24 );  end num_to_date;   最后在我们的查询语句中 select num_to_date(t.limittime) from 表名 t

转载于:https://www.cnblogs.com/moon-jiajun/p/3532463.html