• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

Meaning of this line of code

I run the profiler and there's a duration column. I have this SQL to get the value...not sure of this is seconds or what:

Cast((duration%(1000*60*60))/(1000*60) as varchar(20)) + ':' + cast(((duration%(1000*60*60))%(1000*60))/1000 as varchar(20))

Also this...is this more than 5 seconds?
and ((duration%(1000*60*60))%(1000*60))/1000>= 5
select textdata,duration,

Cast((duration%(1000*60*60))/(1000*60) as varchar(20)) + ':' + cast(((duration%(1000*60*60))%(1000*60))/1000 as varchar(20))

from dbo.trace102611
where textdata is not null

and ((duration%(1000*60*60))%(1000*60))/1000>= 5
order by duration desc

Open in new window

0
Camillia
Asked:
Camillia
  • 3
1 Solution
 
HainKurtSr. System AnalystCommented:
Cast((duration%(1000*60*60))/(1000*60) as varchar(20) = minutes
Cast(((duration%(1000*60*60))%(1000*60))/1000 as varchar(20)) = seconds
0
 
HainKurtSr. System AnalystCommented:
sample:

declare @duration int = 314800;
select Cast((@duration%(1000*60*60))/(1000*60) as varchar(20))
+ ':' +
Cast(((@duration%(1000*60*60))%(1000*60))/1000 as varchar(20))

5:14

(removes fraction, actually it is 5 min, 14 sec, 800 ms = 5 min 14.8 sec)
0
 
HainKurtSr. System AnalystCommented:
it gives you all records for duration > 5 sec
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now