Click here to Skip to main content
15,741,892 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having a table (Table Name -Production) in SQL Server.The Production table have a Column TimeSpent (Datatype- varchar(25)) and stores Number of minutes spent . Example 60,78,23 etc. I want to display TimeSpent in HH:MM Format in a select statement. for example it display 01:00 for 60, 01:18 for 78 and so on. Please help me that how i will write this query.

1 solution

This will give you what you are looking for

SELECT Convert(varchar(5), DATEADD(minute, Convert(int, YOUR-COLUMN-WITH-MINUTES), ''), 108)


SET @TestValue = '130'
SELECT Convert(varchar(5), DATEADD(minute, Convert(int, @TestValue), ''), 108)

-- Result: 02:10
Share this answer
Dharmenrda Kumar Singh 18-Jul-12 9:59am    
Thanks For the Quick Response.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900