Weird behaviour with DATETOSTRING_LOCAL in DQL statements


I am experiencing weird behaviour with the DATETOSTRING_LOCAL function in DQL while trying to group objects based on day.

It behaves identically to the normal DATETOSTRING function unless when it is used in a subquery.

(The real life queries are more complicated than the examples below to illustrate the issue.)

Example 1: normal usage - no issues here

enter image description here

Example 2: the normal DATETOSTRING method behaving as it should

enter image description here
You see the subquery returns the dates correctly as a string in a short format YYYY-MM-dd and the main query can group on it.

Example 3: the localised DATETOSTRING_LOCAL method behaving differently (incorrectly) while using the same query as Example 2

enter image description here
It doesn't format correctly.

Does anybody know why? Is this a bug or an expected, albeit weird, result?

Sign In or Register to comment.