Ms access select data greater than datetime range
Asked Answered
S

2

12

How to select Data in ms access above this datetime range

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

logTime is Datetime field

Swiftlet answered 7/12, 2012 at 19:15 Comment(2)
What's wrong with the query you have?Julius
Don't put it in quotes. Either leave the date as is or add # signs around it. It should just run fine as WHERE logTime >= 12/04/12 , It's not even picky about 12/4/12 opposed to 12/03/2012.Bala
B
24

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#
Bactericide answered 7/12, 2012 at 19:26 Comment(0)
S
0

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

Suburban answered 23/6, 2016 at 12:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.