How to subtract time

  • Hi,

     

    I have a field that is a Time(4) datatype.

    I need to make a computed field in the table that checks if you subtract 52 secs. from the Time field is 0 then 0 else the time field value.

    So I have :

    alter table [DMPCRU].[dbo].[VaspianCalls] add [Hold_Time] as (iif(DATEADD(ss,-52,Duration)<0,0,Duration))

    But this doe not work:

    Comes back with

    Operand type clash: time is incompatible with tinyint

    Any ideas of what I can do?

     

    Thank you

     

     

  • If I understand the desired logic correctly, then this:

    alter table [DMPCRU].[dbo].[VaspianCalls] add [Hold_Time] as (iif(Duration < '00:52', '00:00', Duration))

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • That did it.

    Thanks, I really appreciate your help.

    Thank you

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

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