Solved

# Meaning of this line of code

Posted on 2011-10-26
168 Views
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
``````
0
Question by:Camillia

LVL 51

Expert Comment

Cast((duration%(1000*60*60))/(1000*60) as varchar(20) = minutes
Cast(((duration%(1000*60*60))%(1000*60))/1000 as varchar(20)) = seconds
0

LVL 51

Accepted Solution

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

LVL 51

Expert Comment

it gives you all records for duration > 5 sec
0

## Featured Post

### Suggested Solutions

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…