SQL Query

BGM

Limp Gawd
Joined
Jul 6, 2001
Messages
456
Hmm, anybody know how might i go about figuring out the duration between two time fields with an sql query if they are both in the same table..

iv searched online, but its not very clear, any help would be apprecited :D

cheers!
 
i haven't tried it or anything, but can you do
Code:
SELECT (time2-time1) AS time_diff FROM table;
or perhaps there's a subtraction function
 
It is that easy if they are on the same row.... which I think is what you want to do. That will give you days between dates. Often conversions or functions and such can help and are used with dates. I use DATEDIFF function in SQL Server while Oracle and stuff has there own. Don't know of an ANSI standard.

Edit:whoops... forgot the time was a part of your Q.... Dunno bro. hmm... ? Sorry.
 
spoke to a friend of mine, he seems to think its something along the lines of

Code:
Date_format ( date_sub(endtime-starttime) , %hours %minutes %seconds )

ill go test it out in a mind when i have set up the database etc :D
 
you haven't mentioned what sql server you are using
 
oh sorry, its MySQL.. any one got any ideas :/

i was kind of hopeing there was a function that could manipulate and do calculations on time values..
 
Back
Top