You must Sign In to post a response.
  • Category: SQL Server

    How to convert to Time Format 7.0 to 07:00 in sql server?


    Are you looking for information on time format conversion? Want to know how to convert to Time Format 7.0 to 07:00 in sql server? Read this thread to learn more about time format conversion with examples.



    hi ,

    i need to convert time format

    my input is 7.0
    i want 07:00
  • #730052
    Hi Kumar,

    Try this...

    declare @Time varchar(10)
    set @Time='7.0'
    set @Time=REPLACE(@Time,'.',':')
    select left(convert(varchar(10),convert(datetime,@Time),8),5) as Time

    Regards,
    Sri

  • #730055
    below code might help


    select cast(7.0 as numeric(36,2))

    Thanks!
    Regards,
    Narendra

  • #730056
    Hi,

    Try this way, as your input time is having '.' so we need to convert that to ':' then only we can easily convert that to time and display.

    Declare @CustTime varchar(10)
    set @CustTime = '7.0'
    set @CustTime = REPLACE(@Time,'.',':')
    select CONVERT(varchar(15),CAST(@CustTime AS TIME),100)

  • #730348
    SELECT
    timeFromSeconds(SUM(DATEDIFF(SECOND, t.Pydate, t.DelDate))) AS 'HH:MM:SS'
    FROM
    Transaction_tbl t
    WHERE
    t.transactID in (24, 25)
    group by
    tid

    hope this will help...

  • #731656
    Hi

    SELECT CONVERT(VARCHAR(11),GETDATE(),106)

    Refer this Link:
    http://www.sql-programmers.com/time-and-date-formats.aspx


    Hope this will help you

    SQL Server Programmers and Consultants


  • Sign In to post your comments