Access Query - DateTime

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
 
R

Rick Brandt

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.
 
R

Rick Brandt

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".
 
F

Fritz Switzer

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.
 
R

Rick Brandt

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'.
 
F

Fritz Switzer

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'.
 
Top