1.oracle怎么把数值型日期转换成日期字符型
如20140518转成2014--05-18这种格式的,前者是数值型,后者是字符型
答案:select to_char(to_date(to_char(20140518),‘YYYYMMDD‘),‘YYYY-MM-DD‘) from dual
2. 日期和字符转换函数用法(to_date,to_char)
select to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘) as nowTime from dual; //日期转化为字符串
select to_char(sysdate,‘yyyy‘) as nowYear from dual; //获取时间的年
select to_char(sysdate,‘mm‘) as nowMonth from dual; //获取时间的月
select to_char(sysdate,‘dd‘) as nowDay from dual; //获取时间的日
select to_char(sysdate,‘hh24‘) as nowHour from dual; //获取时间的时
select to_char(sysdate,‘mi‘) as nowMinute from dual; //获取时间的分
select to_char(sysdate,‘ss‘) as nowSecond from dual; //获取时间的秒
select to_date(‘2004-05-07 13:23:44‘,‘yyyy-mm-dd hh24:mi:ss‘) from dual//
原文:http://www.cnblogs.com/ChineseMoonGod/p/4441236.html