zoukankan      html  css  js  c++  java
  • MS Access 按时间段查询数据

    Access 总是有各种各样的坑。

    比如数据查询需要按时间段进行查询,需要精确到秒:

    查询一:(不能用)

    select * from [YourTable] where [YourTimeField] >= #2014/04/04 14:24:03# and [YourTimeField] <= #2014/04/04 14:24:05#

    看起来好像一切正常,但是实际返回的数据为空,不能用。

    查询二:(不能用)

    select * from [YourTable] where [YourTimeField] >= '2014/04/04 14:24:03' and [YourTimeField] <= '2014/04/04 14:24:05'

    可能会因为系统配置的时间格式不同产生不同结果

    查了半天资料,找到下面两种查询方式:

    查询三:(OK)

    select * from [YourTable] where DateDiff("s", [YourTimeField] ,#2014/04/04 14:24:03#) <= 0 and DateDiff("s", [YourTimeField] ,#2014/04/04 14:24:05#) >= 0

    查询四:(OK)

    select * from [YourTable] where
    format([YourTimeField], "yyyymmddhhmmss") >= format(#2014/04/04 14:24:3#,"yyyymmddhhmmss")
    and format([YourTimeField], "yyyymmddhhmmss") <= format(#2014/04/04 14:24:05#,"yyyymmddhhmmss")

  • 相关阅读:
    P站画师 GTZ taejune 精选4k插画壁纸
    点、向量与坐标系
    一些几何
    画直线算法 Line drawing algorithm
    DX11 学习大纲
    插值 Interpolation
    The History of Computer Graphics
    vue中的请求拦截响应
    Event loop
    小程序使用wx.navigateTo()跳转失败
  • 原文地址:https://www.cnblogs.com/djian/p/3664129.html
Copyright © 2011-2022 走看看