0

I am trying to calculate date diff and getting below error.

Arithmetic overflow error converting expression to data type datetime.

Below is my code

select (CONVERT(DECIMAL,((dbo.convertToUnixTime(GETDATE())-tr.created))))/86400
from Allreporting  tr
10
  • Show the data and definitions of the objects of the query. Commented Sep 4, 2019 at 8:39
  • @Serg 2018-11-20 17:25:25.000 is the format of created. Created is a datetime column Commented Sep 4, 2019 at 8:50
  • @Serg I want to get days open from the above query.So using datediff from current date to create date Commented Sep 4, 2019 at 8:52
  • can you show us value of dbo.convertToUnixTime(GETDATE()) please Commented Sep 4, 2019 at 8:56
  • Hi @Ven 1567587455 is the value of dbo.convertToUnixTime(GETDATE()) Commented Sep 4, 2019 at 8:58

1 Answer 1

1

You want datediff Demo:

select datediff(dd,cast ('2018-11-20 17:25:25.000' as datetime) /* tr.created*/, getdate()) days
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.