Mailing List webobjects-dev@wocommunity.org Message #322
From: Wolfgang Hartmann <webobjects-dev@wocommunity.org>
Subject: Re: [WO-DEV] Re: How would you create such an EOQualifier representing Postgresql date_trunc(...)?
Date: Fri, 5 Nov 2021 07:16:52 +0000
To: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
Another alternative:

Assuming your requested date is in variable "today" which is already truncated to time 00:00:

ERQ.And(
CheckInTime greaterThanOrEqual today,
CheckInTime lessThan today.AddDays(1)
)

Then your code would be db-independent.

Best Regards,
Wolfy

From: WebObjects & WOnder Development <webobjects-dev@wocommunity.org> on behalf of Hugi Thordarson <webobjects-dev@wocommunity.org>
Sent: Thursday, November 4, 2021 11:12:40 AM
To: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
Subject: [WO-DEV] Re: How would you create such an EOQualifier representing Postgresql date_trunc(...)?
 
Could also use a read format. Just tested this and seems to work:

https://gist.github.com/hugith/c97ec7b15b29db8912506db75af9f412

Then there's good old EOSQLQualifier. It's deprecated, but what isn't these days :)

new EOSQLQualifier( EOUtilities.entityNamed( ec, "SomeEntityName" ), "date_trunc('day', CHECK_IN_TIME) >= date_trunc('day', REQUESTED)", null );

- hugi



> On 3 Nov 2021, at 22:15, Ramsey Gurley <webobjects-dev@wocommunity.org> wrote:
>
> Hi Markus,
>
> You could create a derived attribute in your model for the truncated value, but it would calculate that every time you fetch rows as well.
>
> Ramsey
>
>> On Nov 3, 2021, at 9:48 PM, Markus Ruggiero (rucotec) <webobjects-dev@wocommunity.org> wrote:
>>
>> No one?
>> I can live with raw rows but would have been great if anyone knows
>>
>> ---markus---
>>
>>> On 1 Nov 2021, at 12:54, Markus Ruggiero (rucotec) <webobjects-dev@wocommunity.org> wrote:
>>>
>>> Need to find objects satisfying the following condition:
>>>
>>> CHECK_IN_TIME must be at least on the same day or later than REQUESTED. Both values are stored as NSTimestamp with a 15 minutes precision.
>>>
>>> In Postgres I would write
>>>
>>> ...where date_trunc('day', CHECK_IN_TIME) >= date_trunc('day', REQUESTED)
>>>
>>> How can I create a qualifier for this? Is this possible at all or do I have to resort to raw rows for SQL?
>>>
>>> Thanks
>>> ---markus---
>>>
>>>
>>>
>>> Markus Ruggiero
>>>
>>> rucotec GmbH                        web https://rucotec.ch
>>> Steinenvorstadt 79                email markus.ruggiero@rucotec.ch
>>> 4051 Basel / Switzerland         mobile +41 79 508 4701
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>
> Confidentiality Notice: This email, including all attachments and replies thereto, are covered by the Electronic Communications Privacy Act, 18 U.S.C. Sections 2510-2521 and are legally privileged. This information is confidential, and intended only for the use of the individuals or entities named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of this transmitted information is strictly prohibited. Please notify us if you have received this transmission in error. Thank you.


#############################################################
This message is sent to you because you are subscribed to
  the mailing list <webobjects-dev@wocommunity.org>.
To unsubscribe, E-mail to: <webobjects-dev-off@wocommunity.org>
To switch to the DIGEST mode, E-mail to <webobjects-dev-digest@wocommunity.org>
To switch to the INDEX mode, E-mail to <webobjects-dev-index@wocommunity.org>
Send administrative queries to  <webobjects-dev-request@wocommunity.org>

Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster