• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Date constants in predicates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Date constants in predicates


  • Subject: Date constants in predicates
  • From: Timothy Larkin <email@hidden>
  • Date: Wed, 30 Nov 2005 07:38:43 -0500

Suppose the user has a text field in which he can compose a search predicate. For instance, he writes, "name = 'David'", and triggers the action, which causes the program to create and use an NSPredicate object with that string as its query.

This works fine for strings. But how to construct date queries? Suppose he wants all records with a date attribute greater than a specific date? He can't write "date >= 09/01/05" because the date constant is interpreted as an invalid number. He can't write "date >= '09/01/05'", because the date constant is then interpreted as a string. He can't even write "date >= [NSDate dateWithString:@"09/01/05"]", which is just imparseable.

The IB function that automatically produces interfaces to Entities creates a predicate for a date object that is of the form "date.description contains[c] $value", but this is nearly useless, since it is simply a string comparison, and does not permit searching a date as a scalar.


-- Timothy Larkin Abstract Tools Caroline, NY

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Date constants in predicates
      • From: Phil Frost <email@hidden>
  • Prev by Date: Fixed width fonts anomalies (was: Pro Font anomalies)
  • Next by Date: KVC keys vs acronym accessors
  • Previous by thread: Fixed width fonts anomalies (was: Pro Font anomalies)
  • Next by thread: Re: Date constants in predicates
  • Index(es):
    • Date
    • Thread