惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Engineering at Meta
Engineering at Meta
T
Tenable Blog
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
NISL@THU
NISL@THU
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
P
Privacy & Cybersecurity Law Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
Secure Thoughts
N
News and Events Feed by Topic
Google DeepMind News
Google DeepMind News
博客园 - 三生石上(FineUI控件)
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
H
Hacker News: Front Page
I
InfoQ
L
LangChain Blog
Security Latest
Security Latest
The Cloudflare Blog
Forbes - Security
Forbes - Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
量子位
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Visual Studio Blog
Scott Helme
Scott Helme
爱范儿
爱范儿
A
Arctic Wolf
F
Full Disclosure
酷 壳 – CoolShell
酷 壳 – CoolShell
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
C
CXSECURITY Database RSS Feed - CXSecurity.com
L
LINUX DO - 最新话题
V2EX - 技术
V2EX - 技术
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Know Your Adversary
Know Your Adversary
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - Leetle

win2000/xp/2003下完全卸载ORACLE Oracle9i中分区partition的使用 [ZT]Oracle数据库字符集问题解决方案大全 Oracle 8.1.6 for Win2000 系统文件解释 如何连接oracle数据库及故障解决办法 Oracle 9i初始化参数文件 简单冷备份恢复操作步骤 Win 下常用的oracle 9i服务的介绍 oracle初始化参数说明 Oracle中的数据字典技术初级入门 【转帖】揭露不为人所知的招聘网站的秘密, 业内人士告诉你:为何你的简历石沉大海?! 市场盈亏指标CYS的使用技巧 炒股短线招术(完整版) DBA常用SQL语句系列 Function怎么返回一个数据集 Oracle 9i 分析函数参考手册 使用Oracle的分析函数ROW_NUMBER、DENSE_RANK、RANK oracle日期处理完全版(三) oracle日期处理完全版(二)
oracle日期处理完全版(一)
Leetle · 2007-04-06 · via 博客园 - Leetle

TO_DATE格式 
Day: 
dd number 12 
dy abbreviated fri 
day spelled out friday 
ddspth spelled out, ordinal twelfth 
Month: 
mm number 03 
mon abbreviated mar 
month spelled out march 
Year: 
yy two digits 98 
yyyy four digits 1998 

24小时格式下时间范围为: 0:00:00 - 23:59:59.... 
12小时格式下时间范围为: 1:00:00 - 12:59:59 .... 

1. 
日期和字符转换函数用法(to_date,to_char) 

2. 
select to_char( to_date(222,'J'),'Jsp') from dual 

显示Two Hundred Twenty-Two 

3. 
求某天是星期几 
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') 

4. 
两个日期间的天数 
select floor(sysdate - to_date('20020405','yyyymmdd')) from dual; 

5. 时间为null的用法 
select id, active_date from table1 
UNION 
select 1, TO_DATE(null) from dual; 

注意要用TO_DATE(null) 

6. 
a_date between to_date('20011201','yyyymmdd') and to_date('20011231','yyyymmdd') 
那么12月31号中午12点之后和12月1号的12点之前是不包含在这个范围之内的。 
所以,当时间需要精确的时候,觉得to_char还是必要的 
7. 日期格式冲突问题 
输入的格式要看你安装的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