Page 1 of 1

mySQL can I subtract TIMEDATE from TIMEDATE and get TIME

Posted: Fri Jul 11, 2014 9:47 pm
by DavJans
I'm trying to calculate delay
I have three columns in my database starttime, finishtime, and delay
starttime and finishtime are both DATETIME values
delay I just want TIME
anyone know how I would do this?

Re: mySQL can I subtract TIMEDATE from TIMEDATE and get TIME

Posted: Fri Jul 11, 2014 10:10 pm
by DavJans
Looked into timestampdiff a little but would be nice to get the answer in a HH:MM:SS format

Re: mySQL can I subtract TIMEDATE from TIMEDATE and get TIME

Posted: Sat Jul 12, 2014 12:00 am
by DavJans
Figured it out!!
If you need this for yourself here is what I made work.
If you know a more efficient way to do it, please let me know

Code: Select all

   put fld "qc" into tqc
   put "SELECT errordate FROM nonc WHERE id=" & tid  into tSQL
   put revDataFromQuery(comma, cr, gConnectionID, tSQL) into tStartTime
   put "UPDATE nonc SET qcdone=" & tqc & ", donedate=NOW(), pinkflag=0 WHERE id=" & tid into tSQL
   revExecuteSQL gConnectionID, tSQL
   put "SELECT donedate FROM nonc WHERE id=" & tid into tSQL
   put revDataFromQuery(comma, cr, gConnectionID, tSQL) into tFinishTime
   put "SELECT TIMEDIFF('" & tFinishTime & "', '" & tStartTime & "');" into tSQL
   put revDataFromQuery(comma, cr, gConnectionID, tSQL) into timetotal
   put timetotal into fld "delay"
   put "UPDATE nonc SET delay='" & timetotal & "' WHERE id=" & tid into tSQL
   revExecuteSQL gConnectionID, tSQL