Subtarcting seconds from a time

  • Hi,

    I have a time datatype column (Time(4)).

    I want to subtract 52 secs from it.

    This is in a computed column like this:

    (case when [Duration]<'00:52' then '00:00' else [Duration] end)

    This does not work.

    For example, one column has 00:01:16.0000 which is 1 minute and 16 seconds, or 60+16 which is 76 seconds. I want to subtract 52 from this.

    tried using dateadd() but am doing something wrong.

    any Ideas?

    Thank you

  • Oops.  I didn't subtract from the final result:

    (case when [Duration]<'00:52' then '00:00' else DATEADD(SECOND, -52, [Duration]) end)

     

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing 2 posts - 1 through 1 (of 1 total)

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