• 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
Re: Date calculation, NSTimestamp, and PostgreSQL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date calculation, NSTimestamp, and PostgreSQL


  • Subject: Re: Date calculation, NSTimestamp, and PostgreSQL
  • From: Geoff Hopson <email@hidden>
  • Date: Tue, 29 Jun 2004 20:49:09 +0100

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.


  • Follow-Ups:
    • Re: Date calculation, NSTimestamp, and PostgreSQL
      • From: Randall Perry <email@hidden>
References: 
 >Date calculation, NSTimestamp, and PostgreSQL (From: Randall Perry <email@hidden>)

  • Prev by Date: Date calculation, NSTimestamp, and PostgreSQL
  • Next by Date: Re: Date calculation, NSTimestamp, and PostgreSQL
  • Previous by thread: Date calculation, NSTimestamp, and PostgreSQL
  • Next by thread: Re: Date calculation, NSTimestamp, and PostgreSQL
  • Index(es):
    • Date
    • Thread