欢迎投稿

今日深度:

to_char和to_date经验分享

to_char和to_date经验分享


to_char和to_date经验分享
 
  ㈠ 比较下面两种写法:
     
     to_char(start_time,'yyyy-mm-dd hh24:mi:ss')='2013-06-06 16:18:30'
     和
     start_time=to_date('2013-06-06 16:18:30','yyyy-mm-dd hh24:mi:ss')
        
     任何时候都推荐使用后者!!
     
     ㈡ 数字转为英文的简单实现
 
[plain] 
sys@ORCL> select to_char(to_date('1314','J'),'Jsp') as "I love 1314" from dual;  
  
I love 1314  
-----------------------------------  
One Thousand Three Hundred Fourteen  
 
     ㈢ 一个 to_date 的陷阱
     
     我们可以用to_date函数来构造自己想要的任何时间
     当省略了HH,MI,SS时,oracle缺省置为0,即:取整到日
     当省略了DD时,oracle缺省置为1,即:取整到月
     当省略了MM时,oracle会取整到年吗?我们都会惯性的认为:会。然,非也!
     Oracle不会取整到年,他会取整到当前月!
 

www.htsjk.Com true http://www.htsjk.com/oracle/21916.html NewsArticle to_char和to_date经验分享 to_char和to_date经验分享 ㈠ 比较下面两种写法: to_char(start_time,yyyy-mm-dd hh24:mi:ss)=2013-06-06 16:18:30 和 start_time=to_date(2013-06-06 16:18:30,yyyy-mm-dd hh24:mi:ss) 任何时候都推荐使...
相关文章
    暂无相关文章
评论暂时关闭