Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date calculation, NSTimestamp, and PostgreSQL



Thanks. 

I was a bit baffled as to how to proceed, but that dun did it.




on 6/29/04 3:49 PM, Geoff Hopson at email@hidden wrote:

> Try the following instead (you may have to diddle with it - written
> from memory):
> 
> Calendar workingCalendar = Calendar.getInstance();
> workingCalendar.add( Calendar.DAY_OF_MONTH, -365 );
> 
> // convert to NSTimestamp
> NSTimestamp dateOneYearAgo = new NSTimestamp(workingCalendar.getTime());
> 
> NSArray args = new NSArray(new Object[] {key, dateOneYearAgo});
> qual = EOQualifier.qualifierWithQualifierFormat("custNo = %@ and
> dateTime > %@", args);
> 
> etc..
> 
> 
> EOQualkifier tries to parse what you send it. You are sending it a long
> string - it can't convert that to Postgres-speak. But it can substitute
> objects into a qualifier string for you and parse them correctly.
> 
> 
> Good luck!
> Geoff
> 
> 
> On 29 Jun 2004, at 19:21, Randall Perry wrote:
> 
>> I'm creating an EOQualifier to perform a fetch against a PostgreSQL
>> db. I
>> calculate the time one year ago today and place it in an NSTimestamp
>> dateOneYearAgo. NSTimestamp is the java value class in the EOModel for
>> the
>> dateTime field.
>> 
>> When I try to perform the fetch PostgreSQL chokes because the value of
>> the
>> dateOneYearAgo NSTimestamp is "2003-06-30 18:08:39 Etc/GMT", and
>> PostgreSQL
>> expects timestamps like this: "2003-06-30 18:08:39 GMT", or this:
>> "2004-06-29 14:11:20.288774".
>> 
>> So I need a way to format dateOneYearAgo that PostgreSQL will accept.
>> 
>> Any ideas on the best way to accomplish this? (see code below).
>> 
>> 
>> // create Calendar obj and calc date one year ago
>> Calendar workingCalendar = Calendar.getInstance();
>> workingCalendar.add( Calendar.DAY_OF_MONTH, -365 );
>> 
>> // convert to NSTimestamp
>> NSTimestamp dateOneYearAgo = new
>> NSTimestamp(workingCalendar.getTime());
>> 
>> // create qualifier and perform fetch
>> qual = EOQualifier.qualifierWithQualifierFormat("custNo = " + key +
>> "and
>> dateTime > '"  + dateOneYearAgo + "'", null);
>> logInfo = ec.objectsWithFetchSpecification(logFetchSpec);
>> 
>> 
>> -- 
>> Randall Perry
>> sysTame
>> 
>> Xserve Web Hosting/Co-location
>> Website Design/Development
>> WebObjects Hosting
>> Mac Consulting/Sales
>> 
>> http://www.systame.com/
>> _______________________________________________
>> 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.

-- 
Randall Perry
sysTame

Xserve Web Hosting/Co-location
Website Design/Development
WebObjects Hosting
Mac Consulting/Sales

http://www.systame.com/
_______________________________________________
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.


References: 
 >Re: Date calculation, NSTimestamp, and PostgreSQL (From: Geoff Hopson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.