sql 中 datetime日期类型字段比较

mysql

可以直接用大于号,也可以用  between  and

SELECT * FROM staff WHERE UPDATE_DATE >= '2019-08-14 11:41:09' AND UPDATE_DATE <= '2019-08-14 11:41:11';

SELECT * FROM staff WHERE UPDATE_DATE BETWEEN '2019-08-14 11:41:09' AND '2019-08-14 11:41:11';

Oracle

转:

oracle sql日期比较:
在今天之前:
select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update <= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
在今天只后:
select * from up_date where update > to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update >= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
精确时间:
select * from up_date where update = to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
在某段时间内:
select * from up_date where update between to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and update > to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
select * from up_date where update <= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and update >= to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss')
posted on 2007-09-07 16:29 forker 阅读(79520) 评论(6)  编辑  收藏 所属分类: database

sql日期比较的更多相关文章

  1. DB2 SQL 日期函数

    DB2 SQL 日期函数1:CURRENT TIMESTAMP 函数:获取当前日期时间语法:CURRENT TIMESTAMP参数:当前日期时间返回值:当前日期时间 2:CURRENT DATE 函数 ...

  2. oracle sql日期比较

    oracle sql日期比较:在今天之前: select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm ...

  3. Sql日期时间格式转换;取年 月 日,函数:DateName()、DATEPART()

    一.sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, 20) 结果:2007 ...

  4. sql 日期时间格式转换

    Sql日期时间格式转换   sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, ...

  5. sql日期

    当我们处理日期时,最难的任务恐怕是确保所插入的日期的格式,与数据库中日期列的格式相匹配. 只要您的数据包含的只是日期部分,运行查询就不会出问题.但是,如果涉及时间部分,情况就有点复杂了. 在讨论日期查 ...

  6. Sql日期时间格式转换大全

    简介:我们经常会用到sql日期转换,这里列出了日期输出为字符串的所有代码 输出格式 2014-06-12 ), ) 输出格式 2014-06-12 22:31:18 ), ) 以下是各种转换日期代码号 ...

  7. SQL显示某月全部日期明细以及SQL日期格式

    SQL显示某月全部日期明细<存储过程> 方法一: declare @date datetime declare @end datetime ,getdate()) ,@date) crea ...

  8. SQL日期时间函数

    一.Sql Server中的日期与时间函数 1. 当前系统日期.时间  select getdate() 2. dateadd 在向指定日期加上一段时间的基础上,返回新的 datetime 值  例如 ...

  9. SQL——SQL日期

    SQL日期    MySQL:        NOW() 返回当前的日期和时间        CURDATE() 返回当前的日期        CURTIME() 返回当前的时间        DAT ...

随机推荐

  1. python中redis

    一.简介 二.redis的安装和使用 三.python操作readis之安装和支持存储类型 四.python操作redis值普通链接 五.python操作redis值连接池 六.操作之String操作 ...

  2. Linux下相关性能指标数据采集

    1)如何查看某个服务进程所占本机物理内存及百分比情况?可以使用Linux命令行查看,也可以使用脚本实现.如下以查看本机kube-nginx服务进程为例: [root@kevin ~]# pidof k ...

  3. linux crontab 鉴定令牌不再有效,需要新的鉴定令牌 [ You (root) are not allowed to access to (crontab) because of pam configuration.]

    用户root 解决方法: 用root用户,执行 chage -M 99999 root 更改有效期为99999天.

  4. XAMPP启动Apache服务时启动失败

    9:48:49 [Apache] Apache Service detected with wrong path 9:48:49 [Apache] Change XAMPP Apache and Co ...

  5. appium 使用name 定位报错 Locator Strategy 'name' is not supported for this session

    RF中使用 name定位 报错提示: Locator Strategy 'name' is not supported for this session 解决: 1. 打开本地文件 driver.js ...

  6. POJ-2891-Strange Way to Express Integers(线性同余方程组)

    链接: https://vjudge.net/problem/POJ-2891 题意: Elina is reading a book written by Rujia Liu, which intr ...

  7. javascript动态合并表格相同的单元格

    <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Conten ...

  8. 银川区域赛现场赛 Pot!!【线段树】

    给定两个操作: MULTIPLY L R x  区间里都乘以一个数x MAX L R : 计算区间内一个2,3,5,7个数最大值. 思路:维护4个最大值.蓝瘦. /** 有 n 个数和 5 种操作 a ...

  9. Codeforces Round #586

    目录 Contest Info A. Cards B. Multiplication Table C. Substring Game in the Lesson D. Alex and Julian ...

  10. 6、transformation和action1

    一.transformation和action入门 1.介绍 Spark支持两种RDD操作:transformation和action.transformation操作会针对已有的RDD创建一个新的R ...