Home   Wordpress   Log in

TimeSpan.TotalMinutes vs. TimeSpan.Minutes

February 15th, 2006 by admin | Filed under .NET, Mobile.

I was trying to find total minutes an event had been running.

TimeSpan ts = new TimeSpan();
ts = DateTime.Now – myEvent.StartTime;
if (ts.Minutes > 15)>

Compiles and runs… Not actually the behavior I was looking for. This returns the minute value of the time.

Example: time span was 1:12 (1 hour, 12 minutes)

This code evaluated true because 12 is less than 15.

This is the correct code.

if (ts.TotalMinutes > 15)>

This evaluated 72 > 15.

One Response to “TimeSpan.TotalMinutes vs. TimeSpan.Minutes”

  1. Robert | 18/12/09

    Easy mistake to make.

    Searching for “TimeSpan minutes” brings up your page and, since I didn’t notice “TotalMinutes” in intellisense, this was helpful to point it out. Thanks for posting!

Share Your Thoughts

Download Full Movie Online Hytrin Astérix le Gaulois download movie Close Encounters of the Third Kind download movie Ginger Snaps: Unleashed download movie Back to the Future Part II download movie Awakenings download movie Electric Dreams download movie The Crow: Salvation download movie Tarnation download movie Soleil rouge download movie Darkman download movie Whirlwind download movie The hunchback download movie Life stinks download movie Charlie s angels: full throttle download movie Man to man download movie Music and lyrics download movie