Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9069413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:25:16+00:00 2026-06-16T17:25:16+00:00

I have SQL Table like Where DateDiff is in format (hh.mm) DateDiff ATM 1.45

  • 0

I have SQL Table like Where DateDiff is in format (hh.mm)

DateDiff   ATM
1.45       121
1.50       121
1.50       121

When i do Sum of DateDiff by Group by on ATM it will show result like

4.45    121

But the actual Date Time Difference should be

5.25     121

How can we achieve the same in SQL Query

Select Sum(Cast(Convert(Varchar(10),DATEDIFF(HOUR,TicketRaisedOn,ClosedOn))+'.'+
Convert(Varchar(10),DATEDIFF(MINUTE,TicketRaisedOn,ClosedOn)%60) as Numeric(18,2)))[Down Time],ATM 
From Ticket Where Closed=1 And DATEPART(DAYOFYEAR,GETDATE())=DATEPART(DAYOFYEAR,TicketRaisedOn) 
Group BY ATM Order By [Down Time] Desc

TicketRaisedOn & ClosedOn are of DateTime

Database is SQL Server 2008

Above query will print result like this (But its wrong as it will sum it as number not as date time format)

Down Time       ATM
16.95           282
14.46           1811
14.20           52
14.04           936

Sample Data

Select TicketRaisedOn,ClosedOn,ATM 
From Ticket 
Where ATM=282 And DATEPART(DAYOFYEAR,GETDATE())=DATEPART(DAYOFYEAR,TicketRaisedOn) 
And Closed=1

TicketRaisedOn          ClosedOn                ATM
2012-12-21 01:15:23.793 2012-12-21 15:11:59.240 282
2012-12-21 16:42:29.820 2012-12-21 18:21:30.797 282
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:25:17+00:00Added an answer on June 16, 2026 at 5:25 pm

    Do the summing before the formatting

    SELECT
      ATM,
      CONVERT(VARCHAR(10), SUM(DATEDIFF(Minute, TicketRaisedOn, ClosedOn)) / 60)
      + '.' +
      RIGHT('00' + CONVERT(VARCHAR(2), SUM(DATEDIFF(Minute, TicketRaisedOn, ClosedOn)) % 60), 2)
    FROM Ticket
    GROUP BY ATM
    

    Sql Fiddle: http://sqlfiddle.com/#!3/eca01/1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL table like this : sales(product,timestamp) I want to display a
I have a 'users' SQL table structure like this (the ID is randomly generated
I have a 'users' SQL table structure like this (the ID is randomly generated,
If i have a sql table with column like this id version subversion 1
Hi there I have an SQL table that looks like this: CREATE TABLE IF
I have a SQL Server 2008 DB with a table like this (Table1): ID
I have a SQL table with periodic measurements. I'd like to be able to
i've a table like: i have to make sql query to get the average
Possible Duplicate: Concatenate row values T-SQL I have a table like this: ref_num name
I have a table like this in SQL Server: varID(PK) dataID(PK) is_used A 1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.