Date group by functions DAY, Month, Year

I have a document which consists of a date value, example value : 2024-02-16T03:29:48.654159, when I try to run a query on any date functions like DAY() / Month () / Year() I get an error.

How do I accomplish this ? Appreciate your help

Query : SELECT month(req.dateSubmitted) as Month from mybucket req

Error : “msg”: “Invalid function month. - at as”,

See the provided date functions here: https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datefun.html

Since your example date must be stored as a string, try:

SELECT DATE_PART_STR(req.dateSubmitted, "month") ...

HTH,

1 Like

Perfect this helps, exactly what I was looking for

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.