Convert of seconds to percentage value

  • Find the datediff between the last row creationdate and getdate into seconds. Convert the seconds to percentage value.

    DATEDIFF(SS,@CreationDate, getdate())/86400)*100

    will this work?

  • A simple test and you would get the answer 🙂

    Return type of a datediff is integer and you will get 0 i think. So may be this will help you?

    Declare @date datetime

    SET @date = dateadd(mi, 5,getdate())

    SELECT ((convert(float,DATEDIFF(SS, getdate(), @date)))/86400) * 100

    ---------------------------------------------------------------------------------

  • Thanks very much for your help.

  • Sorry, this should also do (its implicit, my bad!)

    Declare @date datetime

    SET @date = dateadd(mi, 5,getdate())

    SELECT (DATEDIFF(SS, getdate(), @date)/86400.00) * 100

    ---------------------------------------------------------------------------------

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

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