Date constants in predicates
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