query criteria to output records from the last 90 minutes
I have a time/date field in my select query and I would like to set the criteria to only output records from the last 90 minutes. please give me the proper SQL 开发者_StackOverflow中文版to copy/paste thanks very much, Nathaniel
SELECT SYSADM_CUSTOMER_ORDER.PRINTED_DATE
FROM SYSADM_CUSTOMER_ORDER;
For MS Access you are looking for something like
SELECT SYSADM_CUSTOMER_ORDER.PRINTED_DATE
FROM SYSADM_CUSTOMER_ORDER
WHERE (((SYSADM_CUSTOMER_ORDER.PRINTED_DATE) Between DateAdd("n",-90,Now()) And Now()));
Have a look at Now Function and DateAdd Function
I'm assuming you're using MS Access with and MS Access backend. Because this is VBA code it will not work in the query screen.
Dim dteBeginTime as Date
dteBeginTime = DateAdd("n", -90, Now())
SELECT SYSADM_CUSTOMER_ORDER.PRINTED_DATE
FROM SYSADM_CUSTOMER_ORDER
WHERE PRINTED_DATE > #" & dteBeginTime & "#;"
精彩评论