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
.
The easiest method i'm aware is:
if( [firstDate timeIntervalSinceDate:secondDate] > 0 ) {
The other answers cover compare:, wanted to add some flavour ;).
To compare dates use -compare:
method:
Return Value If:
- The receiver and anotherDate are exactly equal to each other, NSOrderedSame
- The receiver is later in time than anotherDate, NSOrderedDescending
- The receiver is earlier in time than anotherDate, NSOrderedAscending.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With