Checking if one NSDate is greater than another

Jules picture Jules · Oct 1, 2010 · Viewed 24.6k times · Source
if (datStartDate > datEndDate) {

This doesn't seem to work. I know there's a isEqual, etc., but how do I perform "is greater than"?

There are both NSDate.

Answer

dannywartnaby picture dannywartnaby · Oct 1, 2010

The easiest method i'm aware is:

if( [firstDate timeIntervalSinceDate:secondDate] > 0 ) {

The other answers cover compare:, wanted to add some flavour ;).