sum of the event

  • Hi Every body

    Could you please help me

    Which channels watched most of the time any help me how can write a qurey for this

    stat_id event_no channel event_tim

    001 Pwr_on Etv 07:10:21 CDT06/13/1997

    002 Dtv_ch Gemini 07:10:29 CDT06/13/1997

    003 dtv_guide Etv 07:10:38 CDT06/13/1997

  • What is the data type of the event_tim column? Do I need to find the time difference between row 1 and row 2 in order to get the time a channel was watched? So etv would be watched for 8 seconds and then Gemini for 9 seconds then back to etv, but there is on way of knowing when the last row ended in the data you supplied. What would I do with the last row?

  • hi friend

    thank u for ur reply

    that data type is 'evet_date'

    now could u please give good suggestion how can i calulate the sum of them

  • There is no such thing as an evet_date date type in SQL Server. It could be a user defined type and then you need to let me know what type it is based on.

    I am assuming the data in that column means that event 1 took place on June 13, 1997 at 7:10:21 am. Is that a correct assumption?

  • hi hall

    '19:12:43 CDT 05/23/2007' this is event_date but it is in varchar datatype.

    How can we convert varchar datatype to date time datatype any body plz give suggestion

  • What does the CDT stand for? Are there other values besides CDT in the middle of the time and date?

  • kumar99ms (10/14/2008)


    hi hall

    '19:12:43 CDT 05/23/2007' this is event_date but it is in varchar datatype.

    How can we convert varchar datatype to date time datatype any body plz give suggestion

    You should look at converting these into UTC time, or something based off of a standard time zone. I'm assuming that CDT is Central Daylight time.

    If you were to convert this to UTC time - you'd want to combine the date and time, then cast that as a datetime:

    declare @ts varchar(40)

    set @ts='19:12:43 CDT 05/23/2007'

    select cast(right(@ts,10)+' '+left(@ts, 8) as datetime)

    and then adjust by 5 hours (to get to UTC). Final code would look like:

    declare @ts varchar(40)

    set @ts='19:12:43 CDT 05/23/2007'

    select dateadd(hour,5,cast(right(@ts,10)+' '+left(@ts, 8) as datetime))

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply