On Thu, Nov 6, 2014 at 11:19 AM, [email protected] <[email protected]> wrote:
>
>
>
> On 6 Nov 2014 at 10:16:00, Katsushiro 
> ([email protected](mailto:[email protected])) wrote:
>
>> Hello!
>> Is there any way to compare two dates formatted differently in one XWQL
>> query? Here is my query:
>>
>> /FROM doc.object('$xcontext.macro.params.parentSpaceClass') AS page WHERE
>> :validDate >= $currDate ORDER BY $ordCol
>> $xcontext.macro.params.orderDirection/
>>
>> validDate - variable, which contains date formatted like this (page
>> content): /01/10/2014 14:47:08/
>> $currDate - variable, which contains date formatted like this (from XWili
>> $xwiki.getDate()): /Thu Nov 06 11:09:40 EET 2014/
>>
>> If there is some way I can do this, please, answer me, I'll be incredibly
>> thankful for it. If there isn't, I'll filter gained data with Velocity.
>
> Yes please see the examples at 
> http://extensions.xwiki.org/xwiki/bin/view/Extension/Query+Module
>
> Fo ex:
>

> $services.query.xwql("where doc.creationDate > :date").bindValue('date', 
> $datetool.toDate('yyyy-MM-dd', '2008-01-01')).execute()

In other words:
* always use parameters in where clause, even for $currDate
* don't pass string value for date parameters; pass either a Date
object or a long (timestamp). You can obtain the Date object from your
string using $datetool as shown above

Hope this helps,
Marius

>
> Thanks
> -Vincent
>
>>
>> Thank you for all your answers, Katsu
>
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to