Meaning of this line of code

Posted on 2011-10-26
Last Modified: 2012-05-12
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 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

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
    LVL 51

    Accepted Solution


    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))


    (removes fraction, actually it is 5 min, 14 sec, 800 ms = 5 min 14.8 sec)
    LVL 51

    Expert Comment

    it gives you all records for duration > 5 sec

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    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 ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now