Hi @Rahul Polaboina

Here is sample SELECT script:

SELECT FORMAT(cast('17:00' as datetime),'hh:mm:tt'); 
SELECT FORMAT(cast('14:00' as datetime),'hh:mm:tt'); 

Answer from Chandu_0124 on learn.microsoft.com
Discussions

Converting varchar time HHMM to 24 hour HH:MM:SS? - SQL Server Forums
Microsoft SQL Server articles, forums and blogs for database administrators (DBA) and developers. More on sqlteam.com
๐ŸŒ sqlteam.com
October 29, 2014
sql server 2012 - Converting varchar(6) in HHmmss format to sql time format - Stack Overflow
How is it possible to convert something stored in DB as varchar(6) (e.g., 180000 which is actually in a format of HHmmss) to time, I tried the following but wont work select convert(time,'180000') More on stackoverflow.com
๐ŸŒ stackoverflow.com
sql - TSQL Convert VARCHAR of HHMMSS to TIME - Stack Overflow
I have a VARCHAR field that has sample values as listed below and I would like to convert it to HH:MM:SS. Suggestions? 151200 085800 080100 210100 083300 More on stackoverflow.com
๐ŸŒ stackoverflow.com
November 5, 2019
How to convert hhmm into datetime 13:30:00 T-SQL? โ€“ SQLServerCentral Forums
How to convert hhmm into datetime 13:30:00 T-SQL? Forum โ€“ Learn more on SQLServerCentral More on sqlservercentral.com
๐ŸŒ sqlservercentral.com
December 2, 2008
๐ŸŒ
SQL Team
sqlteam.com โ€บ forums โ€บ topic.asp
Converting varchar time HHMM to 24 hour HH:MM:SS? - SQL Server Forums
October 29, 2014 - Microsoft SQL Server articles, forums and blogs for database administrators (DBA) and developers.
๐ŸŒ
Codelabs365
codelabs365.com โ€บ convert hh:mm:ss string into time type, minutes, or seconds
SQL Server Convert HH:mm:ss String into Time Data Type, the Total Number of Minutes, or the Total Nmber of Seconds. | Codelabs365
DECLARE @timeString VARCHAR(8) = '10:32:59'; declares a variable named @timeString and assigns the value '10:32:59' to it. This variable now holds the input time string in the format HH:mm:ss. DECLARE @time TIME = CONVERT(TIME, @timeString); declares another variable named @time and assigns ...
๐ŸŒ
SQLServerCentral
sqlservercentral.com โ€บ forums โ€บ topic โ€บ how-to-convert-hhmm-into-datetime-133000-t-sql
How to convert hhmm into datetime 13:30:00 T-SQL? โ€“ SQLServerCentral Forums
December 2, 2008 - Converting varchar to datetime T-SQL. ... Jeff's answer will work only if you guarantee that you'll have 4 digits regardless of the value. For example if the time should be 9:05 will you varchar show 0905?
Find elsewhere
๐ŸŒ
MSSQLTips
mssqltips.com โ€บ home โ€บ sql date format examples using convert function
SQL Date Format Examples using SQL CONVERT Function
September 26, 2025 - Use SELECT CONVERT and the format option for the date/time format needed ... Check out the table below for all of the different format options for Dates and Times. The date used for all of these examples is โ€œ2022-12-30 00:38:54.840โ€ (December ...
๐ŸŒ
CopyProgramming
copyprogramming.com โ€บ howto โ€บ tsql-convert-varchar-of-hhmmss-to-time
Sql: Transforming a VARCHAR in HHMMSS format to TIME in T-SQL
March 31, 2023 - Ask Question Asked 5 years, 6 months ago. If you are using SQL Server 2012 or above and want to store the values as actual TIME data types, you can use the TIMEFROMPARTS function. For example: DECLARE @d VARCHAR(10) SET @d = '151200' SELECT โ€ฆ ... Style 121 can be utilized, however, the format ...
๐ŸŒ
Google Sites
sites.google.com โ€บ site โ€บ mssqlserverworkstation โ€บ follow-me โ€บ blog โ€บ howtoconvertfromstringtodatetime
How to convert from string to datetime? - SqlServer Work Station
December 9, 2012 - Execute the following T-SQL scripts in Microsoft SQL Server Management Studio (SSMS) Query Editor to demonstrate T-SQL CONVERT and CAST functions in transforming string SQL date formats, string time & string datetime data to datetime data type. Practical examples for T-SQL DATE / DATETIME functions
๐ŸŒ
SQLTeam
forums.sqlteam.com โ€บ t โ€บ timeformat-hhmmss โ€บ 23669
Timeformat: hhmmss - SQLTeam.com Forums
November 14, 2023 - Hi I need to have the time format in hhmmss SELECT CONVERT(VARCHAR(8),GETDATE(),108) 15:31:42 I need it to be 153142 is there the way to do it? Thanks
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ sql โ€บ t-sql โ€บ functions โ€บ cast-and-convert-transact-sql
CAST and CONVERT (Transact-SQL) - SQL Server | Microsoft Learn
When you convert between datetimeoffset and the character types char, nchar, nvarchar, and varchar, the converted time zone offset part should always have double digits for both HH and MM.
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ func_sqlserver_convert.asp
SQL Server CONVERT() Function
String Functions: Asc Chr Concat with & CurDir Format InStr InstrRev LCase Left Len LTrim Mid Replace Right RTrim Space Split Str StrComp StrConv StrReverse Trim UCase Numeric Functions: Abs Atn Avg Cos Count Exp Fix Format Int Max Min Randomize Rnd Round Sgn Sqr Sum Val Date Functions: Date DateAdd DateDiff DatePart DateSerial DateValue Day Format Hour Minute Month MonthName Now Second Time TimeSerial TimeValue Weekday WeekdayName Year Other Functions: CurrentUser Environ IsDate IsNull IsNumeric SQL Quick Ref
Top answer
1 of 15
176

You want to multiply out to milliseconds as the fractional part is discarded.

SELECT DATEADD(ms, 121.25 * 1000, 0)

If you want it without the date portion you can use CONVERT, with style 114

SELECT CONVERT(varchar, DATEADD(ms, 121.25 * 1000, 0), 114)
2 of 15
63

If your time amount exceeds 24 hours it won't be handled correctly with the DATEADD and CONVERT methods.

SELECT CONVERT(varchar, DATEADD(ms, 24*60*60 * 1000, 0), 114)
00:00:00:000

The following function will handle times exceeding 24 hours (~max 35,791,394 hours).

create function [dbo].[ConvertTimeToHHMMSS]
(
    @time decimal(28,3), 
    @unit varchar(20)
)
returns varchar(20)
as
begin

    declare @seconds decimal(18,3), @minutes int, @hours int;

    if(@unit = 'hour' or @unit = 'hh' )
        set @seconds = @time * 60 * 60;
    else if(@unit = 'minute' or @unit = 'mi' or @unit = 'n')
        set @seconds = @time * 60;
    else if(@unit = 'second' or @unit = 'ss' or @unit = 's')
        set @seconds = @time;
    else set @seconds = 0; -- unknown time units

    set @hours = convert(int, @seconds /60 / 60);
    set @minutes = convert(int, (@seconds / 60) - (@hours * 60 ));
    set @seconds = @seconds % 60;

    return 
        convert(varchar(9), convert(int, @hours)) + ':' +
        right('00' + convert(varchar(2), convert(int, @minutes)), 2) + ':' +
        right('00' + convert(varchar(6), @seconds), 6)

end

Usage:

select dbo.ConvertTimeToHHMMSS(123, 's')
select dbo.ConvertTimeToHHMMSS(96.999, 'mi')
select dbo.ConvertTimeToHHMMSS(35791394.999, 'hh')
0:02:03.000
1:36:59.940
35791394:59:56.400