Oracle中时间的格式

关于0racle中得时间格式:
yyyy:用数字表达的四位数字年(2009)
yyy:年份的最后三位(009)
yy:年份的最后二位(09)
y: 年份的最后一位 (9)
        rr:年份后两位数字(会遇到千年虫问题,考虑本世纪的因素)
        RR:年份后两位数字
mon: 三位字符的月份简写(AUG)
mm:用数字表达二位月(08)
ddd: 年中的第几天
dd:月中的第几天
d: 一周中的星期几
dy: 天的简写名
hh24: 一天中的第几个小时,按24小时计, 取值为00~23
hh,hh12: 一天中的第几个小时,按12小时计
mi: 一小时中的分钟
ssss:从午夜开始过去的秒数
ss: 一分钟中的秒
ww: 年中的第几个星期
w: 该月的第几个星期

   找出三月份入职的员工:
   select first_name,start_date
  from s_emp
   where to_char(start_date,'mm') = 3
  
   或者:select first_name,start_date
         from s_emp
         where to_char(start_date,'fmmm') = ‘3’
注:fm作用为去除前导零
  
   或者:select first_name,start_date
         from s_emp
         where to_char(start_date,'fmmonth') = ‘march’
注:fm作用为去除前导零
   或者:select first_name,start_date
         from s_emp
         where rtrim(to_char(start_date,'month')) = ‘3’
注:rtrim()作用为去除右边的空格
            ltrim()作用为去除左边的空格

猜你喜欢

转载自joysxx.iteye.com/blog/1579929