$dateToString doesn't accept %b - extended month....why?

I’m doing an aggregation on mongo db.
I’m trying to format date field

This works and show me date in this format: 09/01/2023

projectObj.$project.createdAtParsed = { $dateToString: { format: "%m/%d/%Y", date: "$createdAt" } }

Now i need to show extended month name (September, October, etc) so I try to change %m with %B
Thi doesn’t works and give me this error: PlanExecutor error during aggregation :: caused by :: Invalid format character ‘%B’ in format string

projectObj.$project.createdAtParsed = { $dateToString: { format: "%B/%d/%Y", date: "$createdAt" } }

Anyone?

Hello @Giorgio_Brugnone,

The %B Specifier of $dateToString is supported from MongoDB v6.3, and probably you are using a lower MongoDB version than 6.3.

@Giorgio_Brugnone, as @turivishal mentioned this functionality is available (added in SERVER-73402).

If you’re seeing this error you likely weren’t configured to use Rapid Releases in MongoDB Atlas, however when you upgrade your cluster to MongoDB 7.0 these $dateToString format specifiers will be available.

1 Like

Sounds good.
Thank you i try

Uhm, i’m working with MongoDBCompass.
I must find out how to upgrade db version…any suggestions?

@Giorgio_Brugnone assuming your cluster is hosted in MongoDB Atlas the following documentation should help you upgrade the version of your cluster: https://www.mongodb.com/docs/atlas/tutorial/major-version-change/

tnx a lot, i’ll take a look