1,105,310 Community Members

i want to get the raw time btw 2 dates in seconds

Member Avatar
A.Muqeetkhan
Newbie Poster
3 posts since Sep 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

How would it be possible using T-SQL to find the raw amount of time that has passed between when the job started and when the job ended?

i have used this function

datediff(ss,grn_date,GETDATE()) .

this function gets the jobs done how ever if the diffrence btw the dates is huge like grn_date is in u know 2006-1-1 then i get the error that"Arithmetic overflow error converting int to data type numeric." so now what do i do to get the values.

Member Avatar
AleMonteiro
Master Poster
758 posts since Aug 2010
Reputation Points: 115 [?]
Q&As Helped to Solve: 143 [?]
Skill Endorsements: 29 [?]
 
2
 

DateDiff returns an Int not an BigInt, that's why you get the error.

One work arround is to get the minutes and then multiple by 60, to get the seconds, like this:

ABS(CONVERT(BigInt, (DateDiff(minute, grn_date, getDate()))) * 60)

I found the answer in this forum: http://www.sqlservercentral.com/Forums/Topic964359-392-1.aspx

And here it's a more sofisticated analysis: http://sqlanywhere.blogspot.com.br/2010/10/getting-bigint-from-datediff.html

Member Avatar
A.Muqeetkhan
Newbie Poster
3 posts since Sep 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

thanks mates

Member Avatar
AleMonteiro
Master Poster
758 posts since Aug 2010
Reputation Points: 115 [?]
Q&As Helped to Solve: 143 [?]
Skill Endorsements: 29 [?]
 
0
 

You're welcome.

Just mark the thread as solved please.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: