Access Query - DateTime

  • Thread starter Thread starter Fritz Switzer
  • Start date Start date
F

Fritz Switzer

I have a DateTime field in my Access table named AuditTime.

I'm having trouble creating a SQL query that will return all records that
are "older" than 12 hours. I've tried different variations of the
following:

SELECT *
FROM Charts
WHERE (DATEDIFF('hh', [ AuditTime], NOW()) = '12')

"No value given for one or more parameters" is the error message.

TIA,

Fritz
 
Fritz said:
I have a DateTime field in my Access table named AuditTime.

I'm having trouble creating a SQL query that will return all records
that are "older" than 12 hours. I've tried different variations of
the following:

SELECT *
FROM Charts
WHERE (DATEDIFF('hh', [ AuditTime], NOW()) = '12')

"No value given for one or more parameters" is the error message.

SELECT *
FROM Charts
WHERE DATEDIFF('hh', [AuditTime], NOW()) > 12)

DateDiff return an integer so no quotes. Plus "=" would only return records
that are exactly 12 hours old.
 
Rick said:
SELECT *
FROM Charts
WHERE DATEDIFF('hh', [AuditTime], NOW()) > 12)

DateDiff return an integer so no quotes. Plus "=" would only return
records that are exactly 12 hours old.

Also "hh" should be "h".
 
Rick,

thanks for the quick response. but I'm getting an Invalid Procedure Call
with



Plus there was an extra paren.
SELECT *
FROM Charts
WHERE DATEDIFF('hh', [AuditTime], NOW()) > 12)


Any additional ideas,

Fritz


Rick Brandt said:
Fritz said:
I have a DateTime field in my Access table named AuditTime.

I'm having trouble creating a SQL query that will return all records
that are "older" than 12 hours. I've tried different variations of
the following:

SELECT *
FROM Charts
WHERE (DATEDIFF('hh', [ AuditTime], NOW()) = '12')

"No value given for one or more parameters" is the error message.

SELECT *
FROM Charts
WHERE DATEDIFF('hh', [AuditTime], NOW()) > 12)

DateDiff return an integer so no quotes. Plus "=" would only return
records that are exactly 12 hours old.
 
Fritz said:
Rick,

thanks for the quick response. but I'm getting an Invalid Procedure
Call with



Plus there was an extra paren.
SELECT *
FROM Charts
WHERE DATEDIFF('hh', [AuditTime], NOW()) > 12)


Any additional ideas,

See my previous message. 'hh' needs to be 'h'.
 
Bingo !!!

Thanks Rick Happy Thanksgiving



Rick Brandt said:
Fritz said:
Rick,

thanks for the quick response. but I'm getting an Invalid Procedure
Call with



Plus there was an extra paren.
SELECT *
FROM Charts
WHERE DATEDIFF('hh', [AuditTime], NOW()) > 12)


Any additional ideas,

See my previous message. 'hh' needs to be 'h'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top