日期:2014-05-16 浏览次数:20557 次
yy two digits 两位年??????????????? 显示值:07
yyy three digits 三位年??????????????? 显示值:007
yyyy four digits 四位年??????????????? 显示值:2007
mm??? number???? 两位月????????????? 显示值:11
mon??? abbreviated 字符集表示????????? 显示值:11月,若是英文版,显示nov????
month spelled out 字符集表示????????? 显示值:11月,若是英文版,显示november
dd??? number???????? 当月第几天??????? 显示值:02
ddd??? number???????? 当年第几天??????? 显示值:02
dy??? abbreviated 当周第几天简写??? 显示值:星期五,若是英文版,显示fri
day??? spelled out?? 当周第几天全写??? 显示值:星期五,若是英文版,显示friday???????
ddspth spelled out, ordinal twelfth
hh??? two digits 12小时进制??????????? 显示值:01
hh24 two digits 24小时进制??????????? 显示值:13
mi??? two digits 60进制??????????????? 显示值:45
ss??? two digits 60进制??????????????? 显示值:25
Q???? digit???????? 季度????????????????? 显示值:4
WW??? digit???????? 当年第几周??????????? 显示值:44
W??? digit????????? 当月第几周??????????? 显示值:1
12小时格式下时间范围为: 1:00:00 - 12:59:59 ....
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//
select to_char( to_date(222,'J'),'Jsp') from dual?????
select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day') from dual;?????
星期一?????
select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual;?????
monday?????
设置日期语言?????
ALTER SESSION SET NLS_DATE_LANGUAGE='AMERICAN';?????
也可以这样?????
TO_DATE ('2002-08-26', 'YYYY-mm-dd', 'NLS_DATE_LANGUAGE = American')????
select floor(sysdate - to_date('20020405','yyyymmdd')) from dual;????
select id, active_date from table1?????
UNION?????
select 1, TO_DATE(null) from dual;?????
a_date between to_date('20011201','yyyymmdd') and to_date('20011231','yyyymmdd')?????
那么12月31号中午12点之后和12月1号的12点之前是不包含在这个范围之内的。?????
所以,当时间需要精确的时候,觉得to_char还是必要的
输入的格式要看你安装的ORACLE字符集的类型, 比如: US7ASCII, date格式的类型就是: '01-Jan-01'?????
alter system set NLS_DATE_LANGUAGE = American?????
alter session set NLS_DATE_LANGUAGE = American?????
或者在to_date中写?????
select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual;?????
注意我这只是举了NLS_DATE_LANGUAGE,当然还有很多,?????
可查看?????
select * from nls_session_parameters?????
select * from V$NLS_PARAMETERS????
select count(*)?????
from ( select rownum-1 rnum?????
from all_objects?????
where rownum <= to_date('2002-02-28','yyyy-mm-dd') - to_date('2002-?????
02-01','yyyy-mm-dd')+1?????
)?????
where to_char( to_date('2002-02-01','yyyy-mm-dd')+rnum-1, 'D' )?????
not in ( '1', '7' )?????
在前后分别调用DBMS_UTILITY.GET_TIME, 让后将结果相减(得到的是1/100秒, 而不是毫秒).????
select months_between(to_