The cast function in OQL does function but not when using the build in database.
In an example I retrieve all records in a dataset from the MyFirstModule.Entity entity where the test (datetime) field has a value larger than 4/23/2018 1:37 PM. See below.
SELECT A.test as TEST
FROM MyFirstModule.Entity as A
WHERE A.test > CAST('4/23/2018 1:37 PM' AS DATETIME)
When using this function in conjunction with a hsql db this will fail with the error you mentioned, switching to postgres solves the issue. As no mention is made in the documentation that the function is restricted to certain db-type this should be considered as a bug IMHO. But if using the postgres db is an option for you then you now have a work around.