oracle--自定义函数timestamp转date

--timestamp转换为date

 Create or replace function convert_ts_to_date(tstamp timestamp) return date is

V_DATE date;

V_DAY VARCHAR2(2);

V_MONTH VARCHAR2(2);

V_YEAR VARCHAR2(4);

BEGIN

V_DAY:=EXTRACT(DAY FROM tstamp);

V_MONTH:=EXTRACT(MONTH FROM tstamp);

V_YEAR:=EXTRACT(YEAR FROM tstamp);

V_DATE:= to_date(v_DAY || '-'|| V_MONTH || '-'|| V_YEAR,'DD-MM-YYYY');

Return(V_DATE);

end;

返回结果是天数

你可能感兴趣的:(Timestamp)