How to print a Month as String

Hello Guys

I want to Print the month in string format, how to do that?

My date format is in the "dd-mm-yyyy " format.
A date is given and the month included in the date want to print as a string.

Please help me with this.

Try this:

{{ frappe.utils.formatdate("2022-05-02", "MMM") }}

(Replace "2022-05-02" with the variable holding your date)

Thanks, @rmeyer

But it does not work and show me some error “Uncaught (in promise) TypeError: frappe.utils.formatdate is not a function”

What Version of ERPNext are you using? The above works on v13. Maybe try format_date (with an underscore).

Hi @jinsy,

Please apply and check it.

{{ frappe.utils.get_datetime(doc.Select_Date).strftime("%d %B, %Y") }}


eg.
{{ frappe.utils.get_datetime("2022-05-01").strftime("%d %B, %Y") }}

//output
1 May, 2022

Thank You!

Hi @NCP,

Is this server script or client script?

It’s neither a server script nor a client script. The method being called is python, and the {{ curly braces }} are jinja syntax for putting this in an HTML template (i.e., as a print format). If you want to use this in a server script, you could just use the internal part without the curly braces.

@peterg OK Thanks