Saying "today" in predicates, or, "in the last"

  • I'm using predicates in my program and I'd like to know if there is a
    way to say "today"  without physically inserting todays date every
    time I want to use the predicate, as so:

    [NSPredicate predicateWithFormat: @"date == %@", [NSDate date]]

    I know you can also have predicate with replacement values, but
    again, every time I want to use the predicate I'd have to inform it
    of the new date.  Is there any way to just say [NSPredicate
    predicateWithFormat: @"date == today"]?

    The reason I want to know this is because I want to implement "in the
    last 5 days" or such a predicate, where a date would basically have a
    value added then compared against the current date, as so:

    @"date+xdaysorwhatever <= today"

    So if there is simply a better way of expression "in the last X
    whatevers" that would help also.

    Thank you in advance,

    Francisco Tolmasky
previous month october 2005 next month
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today