[oracle] unix time 변환

UNIXTIME를 일반 date형식으로 표현하기

select to_date(‘19700101090000′,’YYYYMMDDHH24MISS’) + unixtime필드명/86400 as u_time from 테이블명

 

select to_date(‘19700101090000′,’YYYYMMDDHH24MISS’) + creation_time/86400 as u_time,local_creation_time from OPC_HIST_MESSAGES

 

sysdate(일반 date형식)를 unixtime 방식으로 표현하기 함수

create or replace function unixtime
return number
is utime number;
begin
select trunc(sysdate – to_date(‘19700101’, ‘yyyymmdd’)) * 86400 – 32400
+ to_char(sysdate,’sssss’) into utime from dual;
return(utime);
end;

String 형 일반 date 형식 넣기 :

to_date(to_char(‘20071224′,’yyyymmdd’),’yyyymmdd’)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s