Re: Comparing Dates & Timestamps
Re: Comparing Dates & Timestamps
- Subject: Re: Comparing Dates & Timestamps
- From: David Griffith <email@hidden>
- Date: Fri, 12 Mar 2004 00:09:41 +0100
> On Mar 11, 2004, at 11:51 AM, David Griffith wrote:
>
>> I have
>> removed the Value Class (Obj-C) column, however is NSCalendarDate the
>> incorrect Value Class? I actually looked it up earlier and noticed it
>> was
>> on Obj-C class. That is the default that EOModeler gave me when I
>> select
>> internal type of Date.
>
> If I recall correctly, EOModeler stores "NSCalendarDate" in the
> eomodel, probably for historic reasons (Obj-C preceded Java as an EOF
> implementation language). But for WO 5, an NSTimestamp is instantiated
> instead of an NSCalendarDate. So as far as the eomodel is concerned,
> its contents are identical whether you display "Value Class (Obj-C)" or
> "Value Class" in EOModeler.
>
>> I am assuming this will give me timestamps for the current time today,
>> and
>> the same time yesterday. I am looking for say a timestamp for today at
>> 00:00:00 and today at 23:59:59 (as I noticed suggested by Chuck in
>> another
>> post) but I'm not sure how to get that.
>
> You stated that you wanted to compare a Date column for equality.
> Because a Date doesn't include hours, minutes, and seconds, it doesn't
> matter that the NSTimestamps being used for comparisons include hours,
> minutes, and seconds. There is only one Date between the current time
> today and that same time yesterday. No need to do the extra work to
> set hours, minutes, and seconds to 0 (i.e., midnight).
>
Yes, I want to compare today's date against the date that was stored in the
database, which as I said is stored as an NSCalendarDate and in the database
it has the form "2004-03-11". However, when I try and filter the list with:
NSTimestamp today = new NSTimestamp();
....
bindings.addObject(distributor);
bindings.addObject(today);
distQualifier = EOQualifier.qualifierWithQualifierFormat("distributor = %@
AND orderDateShipped= %@", bindings);
I get no results. This has to be because of the timestamp having more info
I guess, since when I do the same thing but using, for example,
orderDateShipped <= %@
I get all results prior to the timestamp.
> There's also no need to use 23:59:59 for a comparison; in fact, it
> might not return the correct results in those databases that store time
> in millisecond precision. To match all of today, "orderDate >=
> today_00:00:00 and orderDate < tomorrow_00:00:00" is more correct than
> "orderDate >= today_00:00:00 and orderDate <= today_23:59:59".
>
> Aloha,
> Art
> _______________________________________________
> webobjects-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/webobjects-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.