oracle日期时间型timestamp的深入理解
2013-05-31 00:00
771 查看
1、字符型转成timestamp
2、timestamp转成date型
3、date型转成timestamp
4、获取timestamp格式的系统时间
5、两date的日期相减得出的是天数,而两timestamp的日期相减得出的是完整的年月日时分秒小数秒
注:所以,timestamp要算出两日期间隔了多少秒,要用函数转换一下。
6、to_char函数支持date和timestamp,但是trunc却不支持TIMESTAMP数据类型。
7、timestamp只支持秒的小数点后面六位。
注:ssxff6也可以为ssxff7、ssxff8、ssxff9等,但只到6有效。
8、获取系统时间的语句:
select to_timestamp('01-10月-08 07.46.41.000000000 上午','dd-MON-yy hh:mi:ss.ff AM') from dual;
2、timestamp转成date型
select cast(to_timestamp('01-10月-08 07.46.41.000000000 上午','dd-MON-yy hh:mi:ss.ff AM') as date) timestamp_to_date from dual;
3、date型转成timestamp
select cast(sysdate as timestamp) date_to_timestamp from dual;
4、获取timestamp格式的系统时间
select systimestamp from dual;
5、两date的日期相减得出的是天数,而两timestamp的日期相减得出的是完整的年月日时分秒小数秒
select systimestamp-systimestamp from dual; select sysdate-sysdate from dual;
注:所以,timestamp要算出两日期间隔了多少秒,要用函数转换一下。
6、to_char函数支持date和timestamp,但是trunc却不支持TIMESTAMP数据类型。
7、timestamp只支持秒的小数点后面六位。
select to_char(systimestamp, 'yyyymmdd hh24:mi:ssxff6') FROM dual;
注:ssxff6也可以为ssxff7、ssxff8、ssxff9等,但只到6有效。
8、获取系统时间的语句:
SELECT sysdate,systimestamp,to_char(systimestamp, 'yyyymmdd hh24:mi:ssxff6') FROM dual;
相关文章推荐
- oracle日期时间型timestamp的深入理解
- oracle日期时间型timestamp的深入理解
- oracle日期时间型timestamp的深入理解
- oracle日期时间型timestamp的深入理解
- oracle日期时间型timestamp相关学习
- oracle日期时间型timestamp相关学习
- Oracle 日期时间型 Timestamp 学习
- oracle日期时间型Date和TimeStamp
- 【Maclean Liu技术分 享】深入理解Oracle中 Mutex的内部原理
- 【技术分享】开Oracle调优鹰眼,深入理解AWR性能报告
- 深入理解Oracle表(1):ORDERED和USE_NL
- Oracle中Hint深入理解(原创)
- 深入理解Oracle表(6):堆组织表(HOT)和索引组织表(IOT)的区别
- Oracle中Hint深入理解及其用例(转来慢慢看)
- Oracle中Hint深入理解(原创)
- Oracle中Hint深入理解(原创)
- 深入理解user和schema --oracle 数据库
- Oracle中Hint深入理解
- ORACLE锁机制深入理解