'Mon Aug 05 11:25:35 CST 2019' 类型转换成 2019-08-05 11:25:35
发现to_char和to_date也都不是那么理想,自己写一个吧。
Create function get_datetime(i varchar(255))
returning varchar(255);
define rec_time varchar(255);
define rs_time varchar(255);
define tmp_mon varchar(255);
define tmp_day varchar(255);
define tmp_year varchar(255);
define tmp_hour varchar(255);
let rec_time=i;
set debug file to '/tmp/a.log';
trace on;
select case
when substr(rec_time,5,3)='Jan' then '01'
when substr(rec_time,5,3)='Feb' then '02'
when substr(rec_time,5,3)='Mar' then '03'
when substr(rec_time,5,3)='Apr' then '04'
when substr(rec_time,5,3)='May' then '05'
when substr(rec_time,5,3)='Jun' then '06'
when substr(rec_time,5,3)='Jul' then '07'
when substr(rec_time,5,3)='Aug' then '08'
when substr(rec_time,5,3)='Sep' then '09'
when substr(rec_time,5,3)='Oct' then '10'
when substr(rec_time,5,3)='Nov' then '11'
when substr(rec_time,5,3)='Dec' then '12'
end
into tmp_mon from sysmaster:sysdual;
select substr(rec_time,9,2) into tmp_day from sysmaster:sysdual;
select substr(rec_time,12,8) into tmp_hour from sysmaster:sysdual;
select substr(rec_time,25,4) into tmp_year from sysmaster:sysdual;
let rs_time=tmp_year||"-"||tmp_mon||"-"||tmp_day||" "||tmp_hour;
return rs_time;
end function;