--根据当前时间戳获取年月日时分秒,其中sysdate不能用于获取时分秒
select systimestamp,
extract(year from systimestamp) year
,extract(month from systimestamp) month
,extract(day from systimestamp) day
,extract(hour from cast(systimestamp as timestamp)) hour
,extract(minute from systimestamp) minute
,extract(second from systimestamp) second
,extract(timezone_hour from systimestamp) th
,extract(timezone_minute from systimestamp) tm
,extract(timezone_region from systimestamp) tr
,extract(timezone_abbr from systimestamp) ta
from dual
  • 使用extract比较两个时间,是最好的选择

    比较两个时间之间相差得小时数,代码如下:

 select t.* from tableName t where EXTRACT(day FROM(systimestamp - t.update_date))*24+
EXTRACT(hour FROM(systimestamp - t.update_date))+
EXTRACT(minute FROM(systimestamp - t.update_date))/60+
EXTRACT(second FROM(systimestamp - t.update_date))/60/60)>=2

oracle使用 extract获取当前时间,并比较两个时间的更多相关文章

  1. JAVA 时间差距,两个时间相差多少天,时,分,秒

    JAVA 时间差距,两个时间相差多少天,时,分,秒 package io; import java.text.DateFormat; import java.text.ParseException; ...

  2. oracle 两个时间相减

    oracle 两个时间相减默认的是天数 oracle 两个时间相减默认的是天数*24 为相差的小时数 oracle 两个时间相减默认的是天数*24*60 为相差的分钟数 oracle 两个时间相减默认 ...

  3. ORACLE中如何查找定位表最后DML操作的时间小结

    在Oracle数据库中,如何查找,定位一张表最后一次的DML操作的时间呢? 方式有三种,不过都有一些局限性,下面简单的解析.总结一下. 1:使用ORA_ROWSCN伪列获取表最后的DML时间 ORA_ ...

  4. 关于oracle数据库中获取版本号类数据最大值的sql

    目前还在高度加班中,但是本次内容怕自己忘记,好不容易解决的,所以赶紧先随便抽点时间记录下,也没来得及考虑效率什么的优化问题,免得以后忘记了. 测试库结构如下: 表名为 testtab 字段名为test ...

  5. oracle 查询表中数据行(row)上最后的DML时间

    在这介绍Oracle 10G开始提供的一个伪列ORA_ROWSCN,它又分为两种模式一种是基于block这是默认的模式(块级跟踪):还有一种是基于row上,这种模式只能在建里表时指定ROWDEPEND ...

  6. oracle中extract()函数----用于截取年、月、日、时、分、秒

    oracle中extract()函数从oracle 9i中引入,用于从一个date或者interval类型中截取到特定的部分 语法如下: extract ( { year | month | day ...

  7. MySql查询系统时间,SQLServer查询系统时间,Oracle查询系统时间

    转自:https://blog.csdn.net/haleyliu123/article/details/70927668/ MySQL查询系统时间 第一种方法:select current_date ...

  8. js(jQuery)获取时间的方法及常用时间类

    获取JavaScript 的时间使用内置的Date函数完成 var mydate = new Date();mydate.getYear(); //获取当前年份(2位)mydate.getFullYe ...

  9. PHP 获取中国时间,即上海时区时间

    /** * 获取中国时间,即上海时区时间 * @param <type> $format * @return <type> */ function getChinaTime($ ...

随机推荐

  1. CF_2018-2019 Russia Open High School Programming Contest (Unrated, Online Mirror, ICPC Rules, Teams Preferred)

    只做了两个就去上课去啦... A. Company Merging time limit per test 1 second memory limit per test 512 megabytes i ...

  2. thinkphp实现like模糊查询实例

    原网址:https://www.jb51.net/article/56846.htm

  3. python全栈开发 * 表格标签 表单标签 css 引入方式 * 180807

    html部分 一.表格标签<table> 1.一个表格<table>由每行<tr>组成的,每行是由<td>组成的. 注意: 一个表格是由行组成的(行是由 ...

  4. 多个if语句和else if区别

    多个if是所有的if都会进行判断if else if是只要有满足条件的,就不再对之后的else if进行判断比如a = 2;if(a==1) c=1;if(a==2) c=2;if(a%2==0) c ...

  5. CSP201312-4 有趣的数【dp】

    问题描述 试题编号: 201312-4 试题名称: 有趣的数 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 我们把一个数称为有趣的,当且仅当: 1. 它的数字只包含0, 1, ...

  6. 安装配置Greenplum

    一.规划 1.服务器: 192.168.0.191   gpdb01        # master 192.168.0.192   gpdb02        # primary segment . ...

  7. RMAN备份filesperset用法

    用filesperset控制备份集的尺寸 当指定filesperset参数时,rman比较filesperset与自动计算出来的值(对每个已分配通道的文件数目) 并取其中较小的那个值来保证所有的通道被 ...

  8. 一键启动frida server的cmd脚本

    和以前写过的在pc直接操作的手机端的sqlite的脚本类似,需要用到重定向的命令 frida-server_helper.bat su /data/local/tmp/frida-server fri ...

  9. redis 3.2 新数据结构:quicklist、String的embstr与raw编码方式分界点

    Redis3.2.0引入了新的quicklist的数据结构做了list的底层存储方案.废弃了原来的两个配置参数, list-max-ziplist-entries list-max-ziplist-v ...

  10. JavaScript 中 return,return true,return false

    1.return: ①return + 表达式,调用函数,并返回表达式的值 ②return,终止函数 ③当代码执行到return语句时,函数返回一个结果就结束运行了,return后面的语句根本不会执行 ...