oracle使用 extract获取当前时间,并比较两个时间
--根据当前时间戳获取年月日时分秒,其中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获取当前时间,并比较两个时间的更多相关文章
- JAVA 时间差距,两个时间相差多少天,时,分,秒
JAVA 时间差距,两个时间相差多少天,时,分,秒 package io; import java.text.DateFormat; import java.text.ParseException; ...
- oracle 两个时间相减
oracle 两个时间相减默认的是天数 oracle 两个时间相减默认的是天数*24 为相差的小时数 oracle 两个时间相减默认的是天数*24*60 为相差的分钟数 oracle 两个时间相减默认 ...
- ORACLE中如何查找定位表最后DML操作的时间小结
在Oracle数据库中,如何查找,定位一张表最后一次的DML操作的时间呢? 方式有三种,不过都有一些局限性,下面简单的解析.总结一下. 1:使用ORA_ROWSCN伪列获取表最后的DML时间 ORA_ ...
- 关于oracle数据库中获取版本号类数据最大值的sql
目前还在高度加班中,但是本次内容怕自己忘记,好不容易解决的,所以赶紧先随便抽点时间记录下,也没来得及考虑效率什么的优化问题,免得以后忘记了. 测试库结构如下: 表名为 testtab 字段名为test ...
- oracle 查询表中数据行(row)上最后的DML时间
在这介绍Oracle 10G开始提供的一个伪列ORA_ROWSCN,它又分为两种模式一种是基于block这是默认的模式(块级跟踪):还有一种是基于row上,这种模式只能在建里表时指定ROWDEPEND ...
- oracle中extract()函数----用于截取年、月、日、时、分、秒
oracle中extract()函数从oracle 9i中引入,用于从一个date或者interval类型中截取到特定的部分 语法如下: extract ( { year | month | day ...
- MySql查询系统时间,SQLServer查询系统时间,Oracle查询系统时间
转自:https://blog.csdn.net/haleyliu123/article/details/70927668/ MySQL查询系统时间 第一种方法:select current_date ...
- js(jQuery)获取时间的方法及常用时间类
获取JavaScript 的时间使用内置的Date函数完成 var mydate = new Date();mydate.getYear(); //获取当前年份(2位)mydate.getFullYe ...
- PHP 获取中国时间,即上海时区时间
/** * 获取中国时间,即上海时区时间 * @param <type> $format * @return <type> */ function getChinaTime($ ...
随机推荐
- File类中的一些属性 添加删除文件夹
import java.io.File; import java.io.IOException; public class FileD { public static void main(String ...
- Win7 IIS配置
一.首先,在开始打开你的控制面板 二.进入到控制面板,选择程序和功能,点击进入 三.在程序与功能中,左菜单栏,打开你的Windows工能 四.在Windows工能中,把你的Internet信息服务中的 ...
- ASP.NET JS调用WebService——简单例子
一.创建好WebService 二.编辑页面与js 三. 运行页面并点击按钮,结果如下 简单调用吧!
- 2019.3.22 JMeter基础操作
1.添加线程组:testplan—添加—线程(用户)Threads(Users) 线程属性值:线程数(虚拟用户数).Rump-up(准备时长:设置所有线程全部启动时间).循环次数(每个线程重复发送请求 ...
- mysql 5.7 laravel json类型数据相关操作
2018年10月16日18:14:21 官方文档中文翻译版 原文:https://dev.mysql.com/doc/refman/5.7/en/json.html 最后有部分实例和一个小总结 11. ...
- jsplumb 使用总结
1 删除连线问题 funcion clearDrawGraph { if (this.graphInstance !== null) { const connections = this.graphI ...
- CSCI 1100 — Computer Science 1 Homework
CSCI 1100 — Computer Science 1 Homework 8CS1 Multiverse: ClassesOverviewThis homework is worth 100 p ...
- 《Mysql 锁》
一:什么是锁? - 锁是计算机协调多个进程或纯线程并发访问某一资源的机制. - 通俗的来说,锁是一种对资源的保护形式. 二:锁分类 - 表级锁 - 开销小,加锁快,没有死锁,锁定粒度大,发生锁冲突的概 ...
- Windows10 正式企业版激活
一.镜像 https://www.landiannews.com/archives/51102.html 二.ISO镜像文件比对SHA1值,判定文件是否被篡改 https://msdn.itellyo ...
- Powershell的IIS管理小结
现在微软是积极地拥抱Linux,并推出了net core,服务器也提供无UI的版本,提高服务器的性能.很多云平台也提供了无UI版本的windows服务器,所以IIS的命令管理已经非常的重要了.在网上找 ...