Time Function?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dishan Fernando

    Time Function?

    Hi
    How can I convert integer to time .

    Ex:
    number = 91
    Result = 1h 31m

    Something like that. I want to do it in DATETIME Function!
    Thanks
    Dishan

  • David Portas

    #2
    Re: Time Function?

    This seems to be about formatting a value for display so I suggest you do
    that client-side rather than in the database. SQL Server doesn't have a TIME
    datatype so your time will have to include a date as well. You can just
    ignore the date unless the time value exceeds 86400 (24 hrs) in which case
    your "time" value will then no longer make sense without a value in days as
    well. I'll assume that isn't a problem for you. Try:

    DECLARE @i INTEGER
    SET @i = 91
    SELECT DATEADD(mi,@i,0 )

    --
    David Portas
    SQL Server MVP
    --


    Comment

    • SQLANG

      #3
      Re: Time Function?

      DECLARE @mint INTEGER
      SET @mint = 91
      SELECT convert(varchar (5),DATEADD(mi, @mint,0),114)
      Got it down to h:mi truncating date


      RA
      MCDBA

      Comment

      Working...