Querying Content Repository based on Date not gving right results
Hi All,
We had a requirement in our project, where we query certain node in JCR which has multiple pages and we pull the results based on one jcr property on the page i.e. pubishDate. Theses results are ordered on the front end in form of tiles based on latest publishDate.
This field is filled by the Authors through Dialog box in one component. We have given the xtype of this field as DateField.
We have written the following xpath Query to pull results in Descending order:
/jcr:root/content/test/tagged-content/resource// element(*,nt:base)[(@multifield='{"identify":["Identifier:test1","Identifier:test2"]}')] order by @publishDate descending
Now the issue here is that we had given the format for Date in this dialog property as m/d/Y (this is default as well). As our Authors created the pages in 2017 and entered publish date as eg: 05/28/2017, 08/21/2017, 10/01/2017, etc, this worked fine all n the year 2017 as it was not the relevant factor in deciding the order if we consider same year. But now in 2018, this is not working fine as it is picking up the month first before year based on the property and most of the 2018 pages data is showing the end, though we want it to be shown first.
As we have already lot of content published in production, it is would not be a feasible solution to re-author all publish dates after changing the format to Y/m/d.
So we are looking for some better solution. Can someone suggest any query modification that can resolve this issue.
Another way i could think of is writing a service and modify all the publishDate values from m/d/Y format to Y/m/d e.g.: 08/21/2017 to 2017/08/21
If anyone has any better solution kindly suggest. Thanks..
Thanks,
Aman