Error(s) in OQL query: Unknown function dateformat.

0
Studio Pro: 11.12.4OQL version 2: YesObject type: View EntityDatabase: local built-in database (development)Questions:Is DATEFORMAT actually supported inside View Entity OQL in Mendix 11.12.4?Is there any additional prerequisite for using DATEFORMAT?Has anyone successfully used DATEFORMAT inside a View Entity?Is this a known issue in 11.12.x, or only supported in certain OQL execution contexts (for example Java/OQL API but not View Entities)?Thanks in advance.
asked
2 answers
0

Hi Wang,


Yes, DATEFORMAT is supported in OQL in Mendix 11.12.4. It was introduced in Mendix 11.12.0, and the documentation lists the syntax as:

DATEFORMAT(expression, pattern)

So the Unknown function 'dateformat' error is not expected simply because the app is using OQL version 2.

Since you're using Studio Pro 11.12.4 + View Entity + OQL v2, I would check the following:

  1. Make sure the running app is actually 11.12.4
  2. The screenshot shows Studio Pro 11.12.4, but the Preview data executes the OQL against the running application/database. Mendix notes that the preview uses the currently running app, so if the app was started with an older version/build, the OQL parser can behave differently.
  3. Try:
    • Stop the application completely.
    • Clean/rebuild if necessary.
    • Start it again from Studio Pro 11.12.4.
    • Run the View Entity query again.
  4. Verify the function syntax
DATEFORMAT(YourDateAttribute, 'yyyy-MM-dd')

For example:

SELECT
    a.CreatedDate AS CreatedDate,
    DATEFORMAT(a.CreatedDate, 'yyyy-MM-dd') AS CreatedDateFormatted
FROM MyModule.Asset AS a

DATEFORMAT takes a DateTime expression and a string pattern, and returns a string.

  1. Check whether the OQL query is being executed by an older runtime
  2. This is the part I'd investigate most strongly if Studio Pro is definitely 11.12.4 but the editor still says:
Unknown function 'dateformat'

The function was added specifically in 11.12.0, so an older runtime/parser would explain the discrepancy.


Also, OQL v2 itself is not the problem. View Entities require OQL v2, and Mendix confirms that View Entity queries use the OQL v2 syntax.


So I wouldn't downgrade to OQL v1 or replace the View Entity.

My first test would be to restart the app completely using the same 11.12.4 installation and then run the query again. If it still reports the same error, I'd check the exact OQL expression and whether the app/runtime is really running the 11.12.4 runtime.


Hope this helps.


answered
0

@Gowtham R Additional test screenshot attached below.

answered