Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using DateDiff to find duration in minutes

I am trying to use Datediff to find out the duration between columnA and columnB.

SELECT datediff (minute, stime, etime) from Exceptions2 where stime = [exceptions2].starttime and etime = [exceptions2].endtime 

This produces errors. Can anyone please help me with what I'm doing wrong?

like image 450
Doug Ancil Avatar asked Nov 01 '10 21:11

Doug Ancil


People also ask

How do I get the difference between two dates in hours and minutes in SQL?

The DATEDIFF() function returns the difference between two dates.

How do I get time difference between minutes in SQL?

MySQL TIMEDIFF() Function The TIMEDIFF() function returns the difference between two time/datetime expressions. Note: time1 and time2 should be in the same format, and the calculation is time1 - time2.

How do you use datediff?

To calculate the number of days between date1 and date2, you can use either Day of year ("y") or Day ("d"). When interval is Weekday ("w"), DateDiff returns the number of weeks between the two dates. If date1 falls on a Monday, DateDiff counts the number of Mondays until date2. It counts date2 but not date1.

Does datediff include start and end?

DATEDIFF returns the total number of the specified unit between startDate and endDate.


1 Answers

how about trying this, not sure why you have stime = [exceptions2].starttime and etime = [exceptions2].endtime

SELECT datediff(minute, starttime, endtime) from Exceptions2 
like image 50
Raymund Avatar answered Sep 25 '22 12:09

Raymund