We help IT Professionals succeed at work.
Get Started

SQL TIme calculation

rlking12
rlking12 asked
on
408 Views
Last Modified: 2012-05-12
The calculation works great until you span 2 days.

Such as Oct 28 12pm to 1:30am Oct 29.

Should be 13.5 hours, my statement is returning 14.3

Any help would be greatly appreciated.



 Select Tech_ServiceID,txtTech,txtStartTime,
                txtEndTime,TimeDate,dtdate,
                convert(real,(24 + DateDiff(ss,txtStartTime,txtEndTime) / 3600)%24) +
                convert(real,((60 + (sum(DateDiff(ss,txtStartTime,txtEndTime)) % 3600) / 60) % 60) * .01) as Total_Time,
                Tech_Service_PayCodes.PayCodeDescription as txtPayCode
                from Tech_Service_Time
                LEFT OUTER JOIN Tech_Service_PayCodes ON Tech_Service_Time.txtPayCode = Tech_Service_PayCodes.PayCodeID
                        where timedate = '10-28-11'                
                group by txtTech,Tech_ServiceID,txtStartTime,
                txtEndTime,TimeDate,dtdate,Tech_Service_PayCodes.PayCodeDescription
                order by TimeDate,txtStartTime


THanks......
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE