1、获取系统时间的语句(ssxff6获取小数点后面六位)
select sysdate,systimestamp,to_char(systimestamp, 'yyyymmdd hh24:mi:ssxff6'),
to_char(systimestamp, 'yyyymmdd hh24:mi:ss.ff6') from dual;
2、字符型转成timestamp
select to_timestamp('2011-09-14 12:52:42.123456789', 'syyyy-mm-dd hh24:mi:ss.ff') from dual;
3、timestamp转成date型
select cast(to_timestamp('2011-09-14 12:52:42.123456789', 'syyyy-mm-dd hh24:mi:ss.ff') as date) timestamp_to_date from dual;
4、date型转成timestamp
select cast(sysdate as timestamp) date_to_timestamp from dual;
5、两date的日期相减得出的是天数,而两timestamp的日期相减得出的是完整的年月日时分秒小数秒
select sysdate-sysdate,systimestamp-systimestamp from dual;
select extract(day from inter) * 24 * 60 * 60 +
extract(hour from inter) * 60 * 60 + extract(minute from inter) * 60 +
extract(second from inter) "seconds" from
(
select to_timestamp('2011-09-14 12:34:23.281000000', 'yyyy-mm-dd hh24:mi:ss.ff') -
to_timestamp('2011-09-14 12:34:22.984000000', 'yyyy-mm-dd hh24:mi:ss.ff') inter from dual
);
select extract(second from to_timestamp('2011-09-14 12:34:23.281000000', 'yyyy-mm-dd hh24:mi:ss.ff'))-
extract(second from to_timestamp('2011-09-14 12:34:22.984000000', 'yyyy-mm-dd hh24:mi:ss.ff')) from dual;
注:所以,timestamp要算出两日期间隔了多少秒,要用函数转换一下。
to_char函数支持date和timestamp,但是trunc却不支持TIMESTAMP数据类型。
select sysdate,systimestamp,to_char(systimestamp, 'yyyymmdd hh24:mi:ssxff6'),
to_char(systimestamp, 'yyyymmdd hh24:mi:ss.ff6') from dual;
2、字符型转成timestamp
select to_timestamp('2011-09-14 12:52:42.123456789', 'syyyy-mm-dd hh24:mi:ss.ff') from dual;
3、timestamp转成date型
select cast(to_timestamp('2011-09-14 12:52:42.123456789', 'syyyy-mm-dd hh24:mi:ss.ff') as date) timestamp_to_date from dual;
4、date型转成timestamp
select cast(sysdate as timestamp) date_to_timestamp from dual;
5、两date的日期相减得出的是天数,而两timestamp的日期相减得出的是完整的年月日时分秒小数秒
select sysdate-sysdate,systimestamp-systimestamp from dual;
select extract(day from inter) * 24 * 60 * 60 +
extract(hour from inter) * 60 * 60 + extract(minute from inter) * 60 +
extract(second from inter) "seconds" from
(
select to_timestamp('2011-09-14 12:34:23.281000000', 'yyyy-mm-dd hh24:mi:ss.ff') -
to_timestamp('2011-09-14 12:34:22.984000000', 'yyyy-mm-dd hh24:mi:ss.ff') inter from dual
);
select extract(second from to_timestamp('2011-09-14 12:34:23.281000000', 'yyyy-mm-dd hh24:mi:ss.ff'))-
extract(second from to_timestamp('2011-09-14 12:34:22.984000000', 'yyyy-mm-dd hh24:mi:ss.ff')) from dual;
注:所以,timestamp要算出两日期间隔了多少秒,要用函数转换一下。
to_char函数支持date和timestamp,但是trunc却不支持TIMESTAMP数据类型。
发表评论
-
ORACLE 手工备份与恢复
2013-10-25 09:50 8601、手工冷备 1.1、在非归档模式下,ORACLE只能 ... -
oracle 分页,oracle 随机数
2012-11-16 17:23 853oracle分页 select * from ( sele ... -
Oracle函数next_day
2012-11-14 17:53 1057--获取date日期的下一个星期weekday; next_d ... -
trunc函数截断日期
2012-11-08 14:26 1283截断日期: 先执行命令:alter session set ... -
复杂的SQL语句
2012-10-25 17:30 929--select 语句中执行判断 select sysdate ... -
oracle 密码永不过期
2012-07-06 11:54 16321. 成功安装ORACLE11g后,默认密码有效期为180天, ... -
ORACLE 错误记录
2012-06-29 17:34 8571. ORACL数据库表空间不够,试图增加表空间,之后进行大量 ... -
关于ORA-01034和ORA-27101的一种解决方法(转)
2012-06-29 17:11 19871 先看oracle的监听和oracle的服务是否都启动了。启 ... -
Oracle导出文件
2012-03-13 11:35 934SET echo off --是否显示脚本中正在 ... -
oracle 备份、还原(导入|导出)
2012-01-10 13:42 816下面介绍的是导入导出的实例。 数据导出: 1 将数据库TE ... -
oracle 启动状态介绍
2011-12-09 15:39 13511、startup nomount 读初始化参数文 ... -
数据库性能优化
2011-07-12 14:14 879Oracle数据库性能优化 ... -
oracle死锁处理
2011-05-05 12:10 631--1.查看数据库中那些用户产生了锁 select usern ... -
ORACLE sysdate 相加减
2011-04-27 16:01 7912加法 select sysdate,add_months ... -
oracle job(定时任务)
2011-04-27 13:53 18271、创建job 使用Submit()过 ... -
Oracle snapshot (快照)
2011-03-28 16:56 2853--在BMS中创建快照日志 create snapshot l ... -
Oracle bug 汇总
2011-03-28 11:33 988database link --访问database link ... -
oracle游标
2011-03-11 16:05 1347一 游标是什么 游标字面理解就是游动的光标。 用数据库 ... -
oracle 包、方法、存储过程
2011-03-11 15:30 941--定义包 create or replace package ... -
ORACLE 对象、空间查询、操作
2011-02-23 12:59 2069--查看数据库版本 select * from v$versi ...
相关推荐
本篇文章是对oracle中日期时间型timestamp函数进行了详细的分析介绍,需要的朋友参考下
oracle中TIMESTAMP与DATE比较
oracle中日期类型与unix 时间戳的转换, Unix时间戳记是从'1970-01-01 00:00:00'GMT开始的秒数,表现为整数型。 Oracle中的时间是Date型,以下函数提供了两种时间转换的Oracle函数 --unix时间戳与date时间互转 ...
oracle --timestamporacle --timestamporacle --timestamporacle --timestamporacle --timestamporacle --timestamporacle --timestamporacle --timestamp
oracle timestamp详解 将常用的转换方法及使用注意事项都罗列出来了
对oracle date,timestamp,interval数据类型的详细讲解。
NULL 博文链接:https://bchen.iteye.com/blog/1632845
在Oracle 9i中,按照SQL 99标准,增加了时间间隔型数据INTERVAL YEAR TO MONTH 和 INTERVAL DAY TO SECOND,它们和其他几种数据类型一起使得对时间的处理更加准确。TIMESTAMP、TIMESTAMP WITH TIME ZONE和TIMESTAMP ...
Oracle date 和 timestamp 区别详解 1.DATE数据类型 这个数据类型我们实在是太熟悉了,当我们需要表示日期和时间的话都会想到date类型。它可以存储月,年,日,世纪,时,分和秒。它典型地用来表示什么时候事情...
纯 C 语言实现的日期时间和timestamp互转的 API 调用,可用于嵌入式。函数名极简单明了,无文档。
今天小编就为大家分享一篇pandas实现将日期转换成timestamp,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
在Oracle数据库中,如何查找,定位一张表最后一次的DML操作的时间呢? 方式有三种,不过都有一些局限性,下面简单的解析、总结一下。 1:使用ORA_ROWSCN伪列获取表最后的DML时间 ORA_ROWSCN伪列是Oracle 10g开始...
我们都知道date和timestamp都是对日期和时间的表示,只是两种类型的精确度不同,前者精确到秒,后者精确到小数秒(fractional_seconds_precision),可以是 0 to 9,缺省是6。这篇文章主要介绍了Oralce中TIMESTAMP的...
本文将详细介绍oracle SCN跟TIMESTAMP之间转换,需要的朋友可以参考下
只有日期 可以用Timestamp+SimpleDateFormat解决
Oracle是能够安装在目前为止所有的计算机上并...日期型、期间型:date、timestamp、timestamp with time zone等。 Oracle数据库对象:cluster、数据库联接、触发器、外部程序库、索引、Java类、演算子、表、视图等等
1主要针对连接oracle数据库代码 2解决[Err] ORA-01830: date format picture ends before converting entire input string报错问题代码,主要是将timestamp数据类型进行格式化成正常数据
有关java中的Date,String,Timestamp之间的转化问题