Nathaniel_613
Nathaniel_613

Reputation: 179

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 to copy/paste thanks very much, Nathaniel

SELECT SYSADM_CUSTOMER_ORDER.PRINTED_DATE
FROM SYSADM_CUSTOMER_ORDER;

Upvotes: 1

Views: 767

Answers (2)

Adriaan Stander
Adriaan Stander

Reputation: 166396

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

Upvotes: 1

HK1
HK1

Reputation: 12210

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 & "#;"

Upvotes: 0

Related Questions