oracle中怎么把‘2011-07-03 00:00:00.0’ 转换成‘yyyy-MM-dd’的格式

2024-11-18 08:25:21
推荐回答(2个)
回答1:

select to_char(trunc(to_timestamp('2011-07-03 00:00:00.0','yyyy-mm-dd hh24:mi:ssxff')),'yyyy-mm-dd') from dual;

--不trunc也行,我是为了保险
select to_char(to_timestamp('2011-07-03 00:00:00.0','yyyy-mm-dd hh24:mi:ssxff'),'yyyy-mm-dd') from dual;

回答2:

to_date(‘2011-07-03 00:00:00.0’ ,‘yyyy-MM-dd’)