Query not working between Excel and Access

D

dhess62

When I run this query from Excel it works fine. When I build a query in
Access and try to run it, it will error out saying "missing operator in query
expression 'activity'='TAPE_MOUNT' and
CAST((current_timestamp-start_time)hours as decimal) <= 24 group by
drive_name. I'm not sure why this is happening.

QUERY:
select distinct drive_name,count(*) as NUM_TAPE_MOUNTS from summary where
activity='TAPE MOUNT' and CAST((current_timestamp-start_time)hours as
decimal) <= 24 group by drive_name

Any help would be greatly appreciated,
 
J

John Spencer

Access SQL does not recognize CAST function.

You might want to use the DateDiff function
DateDiff("h",Start_Time,Current_Timestamp)< 24

I assume that the Start_Time and Current_TimeStamp have a date and a
time. Otherwise this makes little sense, because with just times you
would never get a value more than 23.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
D

dhess62

Thanks, I'll give that a try

John Spencer said:
Access SQL does not recognize CAST function.

You might want to use the DateDiff function
DateDiff("h",Start_Time,Current_Timestamp)< 24

I assume that the Start_Time and Current_TimeStamp have a date and a
time. Otherwise this makes little sense, because with just times you
would never get a value more than 23.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 

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

Top