Search code examples
magnoliajcr-sql2

Magnolia JCR-SQL2 order by Date


In the JCR, I've noticed that dates are stored in the format Feb 19, 2015 12:00:00 AM. This means that when you try and order a query by a date, it doesn't seem to work:

SELECT * FROM [mgnl:pages] ORDER BY articlePublishedDate

Will return:

  • Apr 1, 2015 12:00:00 AM
  • Dec 1, 2015 12:00:00 AM
  • Feb 1, 2015 12:00:00 AM

Is there any way to make the ORDER BY clause act as a integer? I've tried CAST(articlePublishedDate AS LONG) but it appears my content repository doesn't like it ...


Solution

  • Ended up sorting in code, as it wasn't supported by my implementation of JCR.