Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# .NET
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 8-Feb-13 7:15am
Edited 8-Feb-13 8:16am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

replace [YourInput] to your time in minuted
Select CAST(([YourInput] / 60) as varchar(2)) + ':' + CAST(([YourInput] % 60) as varchar(2))
the function can be found from the following location[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
Hasham Ahmad at 8-Feb-13 14:15pm
he is looking to do it in SQL server
richcb at 8-Feb-13 14:19pm
The thread is tagged wrong.
PIEBALDconsult at 8-Feb-13 14:20pm
I wouldn't assume that.
PIEBALDconsult at 8-Feb-13 14:20pm
No, he's looking for a C# answer -- see the tags.
richcb at 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.
PIEBALDconsult at 8-Feb-13 14:28pm
It's in the tags.
He's asking for a C# version of the SQL code -- lots of people ask for language translations.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 505
1 OriginalGriff 248
2 ChintanShukla 185
3 Richard Deeming 175
4 Bhavik_Patel 170
0 Sergey Alexandrovich Kryukov 8,688
1 OriginalGriff 7,237
2 CPallini 2,598
3 Richard MacCutchan 2,080
4 Abhinav S 1,888

Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100