简体   繁体   English

日期字符串比较不起作用(MS ACCESS 2010)

[英]Date string Comparison not working (MS ACCESS 2010)

I am trying to get specific record by comparing date string. 我正在尝试通过比较日期字符串来获取特定记录。 Here is the table 这是桌子

UpdateTimeA          -     UpdateUserId
----------------------------------------
2015/09/02 14:39:39  -     User1
2015/09/02 16:57:29  -     User2
2015/09/02 16:58:37  -     User3

And here is the query 这是查询

SELECT UpdateUserId, UpdateTimeA From SubmitSheets 
WHERE UpdateTimeA =DateValue('9/2/2015 4:58:37 PM')

This query returns 0 records UpdateTimeA is a DateTime type field. 该查询返回0条记录UpdateTimeA是DateTime类型字段。

No need to use Format: 无需使用格式:

SELECT UpdateUserId, UpdateTimeA
From SubmitSheets
WHERE UpdateTimeA = #9/2/2015 4:58:37 PM#

Or you can use the serial functions: 或者,您可以使用串行功能:

SELECT UpdateUserId, UpdateTimeA
From SubmitSheets
WHERE UpdateTimeA = DateSerial(2015, 9, 2) + TimeSerial(16, 58, 37)

Please try to use something like this: 请尝试使用以下方式:

SELECT UpdateUserId, UpdateTimeA
From SubmitSheets
WHERE Format(UpdateTimeA, "m/d/yyyy hh:nn:ss AM/PM") = '9/2/2015 4:58:37 PM'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM