Click here to Skip to main content
12,954,856 members (61,805 online)
Rate this:
Please Sign up or sign in to vote.
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 8-Feb-13 7:15am
Updated 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 8-Feb-13 14:15pm
he is looking to do it in SQL server
richcb 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.
richcb 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 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
Top Experts
Last 24hrsThis month
OriginalGriff 6,539
CHill60 3,490
Maciej Los 3,153
ppolymorphe 2,030
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2017
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