Ms access select data greater than datetime range

独自空忆成欢 提交于 2019-12-04 05:19:51

Adding # signs on each end of your date lets Access know that this is a date type.

select * from logevents where logTime>=#12/6/2012 3:54:15 PM#

This depends on if your Access database is created/opened in ANSI 92 mode:
non-ANSI 92: Access uses # ... # around dates and uses * (multiple characters) and ? (one character) for wildcards when using LIKE. For example:

SELECT * FROM logevents WHERE logTime>=#12/6/2012# AND description like 'error'

ANSI 92: Access uses ' ... ' around dates and uses % and ? for wildscards when using LIKE. This mode looks more like how MySQL, Oracle and MSSQL work with dates and wildcards. For example:

SELECT * FROM logevents WHERE logTime>='12/6/2012' AND description like '%error%'

Be sure to check the date format settings. It can dd/mm/yyyy or dd-mm-yyyy or something else, this depends on your regional settings. Just inspect your table for a date column for example data.

To switch to ANSI-92 in Access 2007, but this should not be hard to apply to different versions: -open MS Access -click the Office button on top left -click "Access Options" button -select "Object Designers" from the left pane -look for "Query Design" section, there is an option "SQL Server Compatible Syntac (ANSI 92). -if you have an open database, you can check on "This Database" or check the "Default for new databases" for default setup on all new databases -click "OK" button to accept the changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!