TO_CHAR 是把日期或数字转换为字符串
TO_DATE 是把字符串转换为数据库中得日期类型转换函数
TO_NUMBER 将字符转化为数字
TO_CHAR
使用TO_CHAR函数处理数字
TO_CHAR(number, '格式')
TO_CHAR(salary,’$99,999.99’);
使用TO_CHAR函数处理日期
TO_CHAR(date,’格式’);
TO_NUMBER
使用TO_NUMBER函数将字符转换为数字
TO_NUMBER(char[, '格式'])
TO_DATE
使用TO_DATE函数将字符转换为日期
TO_DATE(char[, '格式'])
数字格式格式
9 代表一个数字
0 强制显示0
$ 放置一个$符
L 放置一个浮动本地货币符
. 显示小数点
, 显示千位指示符
日期格式
格式控制 描述
YYYY、YYY、YY 分别代表4位、3位、2位的数字年
YEAR 年的拼写
MM 数字月
MONTH 月的全拼
MON 月的缩写
DD 数字日
DAY 星期的全拼
DY 星期的缩写
AM 表示上午或者下午
HH24、HH12 12小时制或24小时制
MI 分钟
SS 秒钟
SP 数字的拼写
TH 数字的序数词
“特殊字符” 假如特殊字符
HH24:MI:SS AM 15:43:20 PM
日期例子:
SELECT TO_DATE('2006-05-01 19:25:34', 'YYYY-MM-DD HH24:MI:SS') FROM DUAL
SELECT TO_DATE('2006-05-01 19:25', 'YYYY-MM-DD HH24:MI') FROM DUAL
SELECT TO_DATE('2006-05-01 19', 'YYYY-MM-DD HH24') FROM DUAL
SELECT TO_DATE('2006-05-01', 'YYYY-MM-DD') FROM DUAL
SELECT TO_DATE('2006-05', 'YYYY-MM') FROM DUAL
SELECT TO_DATE('2006', 'YYYY') FROM DUAL
日期说明:
当省略HH、MI和SS对应的输入参数时,Oracle使用0作为DEFAULT值。如果输入的日期数据忽略时间部分,Oracle会将时、分、秒部分都置为0,也就是说会取整到日。
同样,忽略了DD参数,Oracle会采用1作为日的默认值,也就是说会取整到月。
但是,不要被这种“惯性”所迷惑,如果忽略MM参数,Oracle并不会取整到年,取整到当前月。
注意:
1.在使用Oracle的to_date函数来做日期转换时,可能会直觉地采用“yyyy-MM-dd HH:mm:ss”的格式作为格式进行转换,但是在Oracle中会引起错误:“ORA 01810 格式代码出现两次”。如:select to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mm:ss') from dual;原因是SQL中不区分大小写,MM和mm被认为是相同的格式代码,所以Oracle的SQL采用了mi代替分钟。select to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mi:ss') from dual;
2.另要以24小时的形式显示出来要用HH24
select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual;//mi是分钟
select to_char(sysdate,'yyyy-MM-dd HH24:mm:ss') from dual;//mm会显示月份
分享到:
相关推荐
to.setDate(new Date()); mDatas.add(to); mAdapter.notifyDataSetChanged(); mChatView.setSelection(mDatas.size() - 1); mMsg.setText(""); // 关闭软键盘 InputMethodManager imm = ...
Gain a fundamental understanding of Python’s syntax and features with the second edition of Beginning Python, an up–to–date introduction and practical reference. Covering a wide array of Python–...
Gain a fundamental understanding of Python’s syntax and features with this up–to–date introduction and practical reference. Covering a wide array of Python–related programming topics, including ...
Gain a fundamental understanding of Python’s syntax and features with this up–to–date introduction and practical reference. Covering a wide array of Python–related programming topics, including ...
You'll see how to hook into the Slack API to create software that can read and post to chatrooms, respond to commands and hints given in natural conversational language, and build fun and useful bots ...
This sample is deprecated....Firebase Chat for Android A simple chat application that built with Firebase on Android. ...Firebase keeps the list data up to date based on a mapping to a model class. More abo
Source code + tutorial.<END><br>26 , chat.zip This code shows you how to creat a local network chat room so that you and your friends can have a chat room which nowone else can enter<END><br>27 , ...
The in-depth, complete, and up-to-date book on Angular 6. Become an Angular 6 expert today. Updated for Angular, Angular CLI, and Community Style Guide Ready to master Angular? What if you could ...
Get up to date with Go and write code capable of delivering massive world-class scale performance and availability Learn to apply the nuances of the Go language, and get to know the open source ...
It will help you unlock the secrets of building your own up-to-date Scala application while maximizing performance and scalability. What you will learn Use Akka to create a chat service for your app...
Gain a fundamental understanding of Python’s syntax and features with this up–to–date introduction and practical reference. Covering a wide array of Python–related programming topics, including ...
//test to see if the same object is retrieved from the set. if (p1 != &boys.RemoveElement() ) { cout ; } else { cout , the objects are the same \n"; } boys.Add( *p1); boys.Add( *p2); ...
To meet the community, ask general questions and chat about ethminer join [the ethminer channel on Gitter][Gitter]. All bug reports, pull requests and code reviews are very much welcome. ## License...
// call 和 apply 方法都是用来调用“不属于自身的方法”,apply第二参数必须是数组 // 下面的代码相当于 arguments.slice,但是arguments本身没有 slice方法 // slice 方法是用来截取数组 // arguments...
This automation ensures that all stakeholders have access to accurate and up-to-date information about the review process. **5. Verification of Fixes:** After a code review, it is crucial to verify ...
- `msg`: 一个列表,存储聊天消息,每个消息对象包含`user`(发送者ID)、`name`(发送者名字)、`date`(发送时间)和`content`(消息内容) 接下来,我们讨论业务逻辑。当用户A点击用户B的名字,系统会查找是否存在这个...
7. **信息更新与错过**:`with up-to-date information`强调获取最新信息的重要性,`miss this week’s programme`提醒学生不要错过精彩内容。`a number of`和`the number of`区分表示数量的两种表达方式。 8. **...
- `chat` 闲聊,如 "Let's chat about your hobbies." 3. 其他动词类词汇: - `listen to` 听动作,如 "Listen carefully to the instructions." - `hear` 听结果,如 "I could hear the birds singing." - `pick ...
2. up-to-date:形容词,表示“最新的”,常用于描述信息或设备是否跟得上时代。 3. fan:狂热爱好者,对某种事物有极度热情的人。 4. coming:即将来临的,常用来预告即将播出的电视节目。 5. cover:在此处作动词...