views:

7721

answers:

6

I have a ticks value of 28000000000 which should be 480 minutes but how can I be sure? How do I convert a ticks value to minutes?

Thanks

+1  A: 

there are 600 million ticks per minute. ticksperminute

Blounty
+6  A: 

You can do this way :

Timespan duration = new Timespan(tickCount)
double minutes = duration.TotalMinutes;
Think Before Coding
lol - you answered one minute earlier than Jon Skeet, but his answer has more votes!?
Christian Payne
+19  A: 
TimeSpan.FromTicks(28000000000).TotalMinutes;
Patrik Hägne
+16  A: 

A single tick represents one hundred nanoseconds or one ten-millionth of a second. FROM MSDN.

So 28 000 000 000 * 1/10 000 000 = 2 800 sec. 2 800 sec /60 = 46.6666min

Or you can do it programmaticly with TimeSpan:

    static void Main()
    {
        TimeSpan ts = TimeSpan.FromTicks(28000000000);
        double minutesFromTs = ts.TotalMinutes;
        Console.WriteLine(minutesFromTs);
        Console.Read();
    }

Both give me 46 min and not 480 min...

Daok
lol who down voted me? Both mathematical and coded one really give me 46 min and not this 480 min.
Daok
Maybe someone down voted you for rounding 46.6666 to 46? ;-) No, actually, I had down voted you by mistake, I have removed the down vote now. Sorry!
Patrik Hägne
Actually, to be clear, I have not only removed the down vote. I have up voted your comprehensive answer. Sir.
Patrik Hägne
Voted up for including the math version as well as the TimeSpan version.
Rob Kennedy
upvoted for um.. well i just like your answer lol
baeltazor
+7  A: 

The clearest way in my view is to use TimeSpan.FromTicks and then convert that to minutes:

TimeSpan ts = TimeSpan.FromTicks(ticks);
double minutes = ts.TotalMinutes;
Jon Skeet
A: 

TimeSpan.FromTicks( 28000000000 ).TotalMinutes;

Mike Scott