mySQL can I subtract TIMEDATE from TIMEDATE and get TIME

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

mySQL can I subtract TIMEDATE from TIMEDATE and get TIME

Post by DavJans » Fri Jul 11, 2014 9:47 pm

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?
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

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

Post by DavJans » Fri Jul 11, 2014 10:10 pm

Looked into timestampdiff a little but would be nice to get the answer in a HH:MM:SS format
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

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

Post by DavJans » Sat Jul 12, 2014 12:00 am

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
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

Post Reply