i have 2 columns with 'time' datatype in my MySQL table one storing the start time and the other one storing the end time of an event. I store time values in these 2 colums in 'HH:MMS' format.
i have to find out the time difference between these two columns (endtime - starttime). (ie) the total time interval for which the process was running.
i am using the following query for that.
select time_format(etime-stime,'%H') as hour , time_format(etime-stime,'%i') as minutes from tablename";
this is working fine for values in which the endtime minutes is higher than the starttime minutes, eg (starttime - 08:30:00 and endtime - 10:40:00) but when the endtime minute is less than the starttime minute, (starttime - 08:30:00 and endtime - 10:20:00) i am getting null values. So how do over come this. Please help...