3

I am new here and am new to SQL Server (Express). I used the SSMA tool and it converted Access date/time fields to datatime2. The data contains duration data so there is no need for a date. I want to SUM the column but I need to change to a Time or numeric data type due to 8117# errors when I SUM. SQL Server will not allow a conversion using the designer / ALTER commands as there are always implicit/explicit conversion errors. Thank you for any possible solutions you may have to offer.

marc_s
9,0626 gold badges46 silver badges52 bronze badges
asked Mar 1, 2015 at 7:14
1
  • 1
    Remember that time datatype in SQL Server is supposed to used for storing time part, not duration. It cannot handle over 24 hours. Commented Mar 1, 2015 at 8:45

1 Answer 1

4

Presumably your new column has values which are a certain datetime relative to 1-Jan-1900, or some other date.

...in which case, you could rename your column, and create a calculated column with your original column name, which is the number of second (or minutes or whatever granularity you want), so that you can SUM that instead.

Example:

SELECT t = DATEADD(SECOND, SUM(DATEDIFF(SECOND, '19000101', myTimeColumn)), '19000101')
FROM dbo.someTable;
Aaron Bertrand
182k28 gold badges406 silver badges625 bronze badges
answered Mar 1, 2015 at 7:36
1
  • This makes sense. Thanks for your help. I will try it. Commented Mar 16, 2015 at 17:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.