OQL + Datepart

0
HI !   I have a stupid question I'm sure : I have a "Date and time" field in a persistent entity ; with OQL, I need to group all entities by day How can I use DATE_PART function to get the day (without hours, minutes etc) ? Thanks 
asked
3 answers
0

Use

 

GROUP BY DATEPART(DAYOFYEAR, YourDate)

 

But add some logic for a readable presentation because 1-365 is not a common used date format.

answered
-1

See the documentation here: https://docs.mendix.com/refguide/oql-datepart/

So use something like DATEPART(DAY, yourDate)

Regards,

Ronald

answered
-1

Check the OQL-demosite on service.mendixcloud.com and go to OQL-playground: image.png

 

There you can find examples and test your solution.

See example under button image.png:

FROM Sales.Customer AS c
GROUP BY DATEPART(WEEKDAY,Birthday)
SELECT DATEPART(WEEKDAY,Birthday) AS BirthWeekday_Sundayis1, 
              count(*) as NumOfPersons
ORDER BY BirthWeekday_Sundayis1 ASC

 

answered