Sum total duration

Hi Experts,

I would like to request Experts help. Is that any possibilities to build MSSQL formula for total duration at column “Total_Duration” based on data at column TimeIN(time) and TimeOUT(time). Intent to add this formula at “Computed Column Specification” at ( formula) row. Hope Experts will help to create this formula.


CartilloAsked:
Who is Participating?
 
mayank_joshiCommented:
sorry the above will give negative values.it should be:-

(datediff(MINUTE,[TimeIN],[TimeOUT])) 

 (datediff(HOUR,[TimeIN],[TimeOUT])) 

 (datediff(SECOND,[TimeIN],[TimeOUT]))

Open in new window

0
 
mayank_joshiCommented:
you can use
TimeIN-TimeOUT

Open in new window

0
 
mayank_joshiCommented:
sorry

TimeOUT-TimeIN

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
mayank_joshiCommented:
 (datediff(MINUTE,[TimeOUT],[TimeIN])) 

 (datediff(HOUR,[TimeOUT],[TimeIN])) 

 (datediff(SECOND,[TimeOUT],[TimeIN]))

Open in new window


you can use either of the above 3 methods to get time difference in minutes,HOURS or SECONDS respectively.
0
 
qasim_mdCommented:
select DATEDIFF(hh,getdate(), getdate() +2)--+2 is nothing but 2 days

Assign your columns replacing the getdate() and remove the +2.
0
 
CartilloAuthor Commented:
Hi,

Thanks for the help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.