convert time to seconds

hunterboy

New member
Local time
Today, 20:14
Joined
Jul 26, 2004
Messages
8
how do i convert my time field 3:11:07 PM to seconds using microsoft access query sql?
 
Hunter,

I think this should do it:

DateDiff("s", Date() & " 00:00:00 AM", Date() & [YourTimeField])

Wayne
 
SELECT Newlog.Time
DateDiff("s",Date() & " 00:00:00 AM",Date() & [Newlog.Time])
FROM Newlog;

my sql statement is this but i get a syntax error (missing operator) in query expression 'Newlog.Time DateDiff("s",Date() & " 00:00:00 AM",Date() & [Newlog.Time])'

how do i modify it?
 
Hunter,

Your query is returning two fields. Need a comma between them.

Code:
SELECT Newlog.Time,  <-- Add this comma
           DateDiff("s",Date() & " 00:00:00 AM",Date() & [Newlog.Time])
FROM Newlog;

Wayne
 
Hunter,

You can't have a field named "Time". Access has that reserved for its own
use.

Wayne
 
hi Wayne,

i tried renaming the field.. here's my SQL

SELECT Newlog.Timer, DateDiff("s",Date() & " 00:00:00 AM",Date() & [Newlog.Timer])
FROM Newlog;

but it still returns an error....
 
Hunter,

Had to do some research, I don't use times that often.

Code:
SELECT DatePart("h", [Timer]) * 3600 + DatePart("n", [Timer]) * 60 + DatePart("s", [Timer])
FROM Newlog;

Wayne
 

Users who are viewing this thread

Back
Top Bottom