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 8641053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:25:42+00:00 2026-06-12T11:25:42+00:00

i have a bigint field in Microsoft SQL Server 2008R2 filled with ticks (A

  • 0

i have a bigint field in Microsoft SQL Server 2008R2 filled with ticks (A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.)

http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx

and i need to convert the sum of all records to Days:Hours:Minutes:Seconds:Milliseconds.

it works for a single record:

SELECT CONVERT(TIME, DATEADD(ms, duration/10000, 0)) FROM tblMediaFileProperties WHERE FileId = '6C0A849D-95B4-4755-A923-B9DD8F1AF23E'

but if a sum it up to all records using:

SELECT CONVERT(TIME, DATEADD(ms, SUM(duration/10000), 0)) FROM tblMediaFileProperties 

i get a:

Arithmetic overflow error converting expression to data type int.

i know the overflow comes from the CONVERT to Data Type TIME Function…

help’s appreciated, thanks!

  • 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-12T11:25:43+00:00Added an answer on June 12, 2026 at 11:25 am

    It’s too big for DATEADD which only accepts an int.
    Break it into two parts: seconds, then milliseconds.

    SELECT CONVERT(TIME,
              DATEADD(ms, SUM(duration/10000 % 1000),
              DATEADD(ss, SUM(duration/10000000), 0)))
    FROM tblMediaFileProperties 
    

    And if your total duration goes above 1 day, you can use this to get the days and hr:min:sec:ms separately. It’s a matter of cast and string concat if you actually want the result in textual form.

    declare @duration bigint
    set @duration = 1230000000
    SELECT @duration/10000/1000/60/60/24 DAYS,
           CONVERT(TIME,
              DATEADD(ms, SUM(@duration/10000 % 1000),
              DATEADD(ss, SUM(@duration/10000000), 0))) HR_MIN_SEC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with ONE bigint-field. Now I would like to insert millions
I have an SQL table written in MSSQL: create table [action] ( action_id bigint
i have a table with id field type BIGINT in MySQL in hibernate object,
I have simple function consist of one sql query CREATE FUNCTION `GetProductIDFunc`( in_title char
I have a table called People one of the columns is an xml field
I have a table with a field of type bigint. This field store a
I have a table message in mysql id(bigint) sender(int) receiver(int) message(varchar) 1 42 420
I have a table CREATE TABLE `messages` ( `uid` BIGINT NOT NULL , `mid`
I have this table layout: uuid bigint(20) unsigned primary auto_increment timestamp int(11) unsigned name
I have a table defined as follows: CREATE TABLE [dbo].[T]( [FileID] [bigint] NOT NULL,

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.