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) "Money can't buy you happiness." Maybe so, but it can make your unhappiness a LOT more comfortable!

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

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