Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
my first problem : i have to convert 110 minute into time format means 01:50:00 (hh:mi:ss).
how to do this.?

my second problem : i have convert date to minute.But in that case i cant able to convert second into minute and add it to minute.
my calculation is here:
i have date : 1/9/2012 1:30:12AM
convert to minute returns : 90

SELECT     name1, address, mob, city, emailid,(datepart(hh,[date]) * 60) + datepart(n, [date]) + (datepart(ss,[date])/60)
FROM         [user.]
Posted
Updated 8-Feb-13 8:16am
v2

replace [YourInput] to your time in minuted

SQL
Select CAST(([YourInput] / 60) as varchar(2)) + ':' + CAST(([YourInput] % 60) as varchar(2))


the function can be found from the following location

http://stackoverflow.com/questions/2944580/minutes-to-time-in-sql-server[^]
 
Share this answer
 
new System.TimeSpan ( 0 , 150 , 0 ).ToString()


System.DateTime d = System.DateTime.Parse ( "1/9/2012 1:30:12" ) ;
double minutes = d.TimeOfDay.TotalMinutes ;


This yields 90.2 -- what you do with the fractional part is up to you; Round, Ceiling, Floor, etc.

And if you want your SQL to add the seconds as partial minutes, you can change the second 60 to 60.0 -- you should then get 90.2 there are well.
 
Share this answer
 
v3
Comments
Hasham Ahmad 8-Feb-13 14:15pm    
he is looking to do it in SQL server
Richard C Bishop 8-Feb-13 14:19pm    
The thread is tagged wrong.
PIEBALDconsult 8-Feb-13 14:20pm    
I wouldn't assume that.
PIEBALDconsult 8-Feb-13 14:20pm    
No, he's looking for a C# answer -- see the tags.
Richard C Bishop 8-Feb-13 14:25pm    
Look at the code he posted though, it is not C#. Nowhere in his post does it mention any language other than the code posted.

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