ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Get month on print format

Hello,

Can someone give a tip, i am trying to make a custom print, but on place of date, day-month-year, i only want to print month?

any help?

1 Like

Hi Dany,

I’m not sure how to format this directly in Jinja, but I’ll offer a possible workaround.

Create a new custom field (type: data) in the document. This can be hidden if you only want it on the print format.
Add the following to the custom script for that document, changing the doctype, trigger, and custom field name:

frappe.ui.form.on("DocType", {
    trigger: function(frm) {
        var today = new Date();
        var month = new Array();
        month[0] = "January";
        month[1] = "February";
        month[2] = "March";
        month[3] = "April";
        month[4] = "May";
        month[5] = "June";
        month[6] = "July";
        month[7] = "August";
        month[8] = "September";
        month[9] = "October";
        month[10] = "November";
        month[11] = "December";
        var n = month[today.getMonth()];
        frm.set_value("custom_data_field_for_month", date);
    }
});

Then just add the custom field to your print format.

1 Like

@cpurbaugh

hello

i created a new field called “month” and the date field it suppose to fetch the month from is “posting date” which is in a doctype called “salary slip”

still couldn’t get this right … kindly assist

Try
{{ frappe.utils.formatdate(doc.get_formatted(‘transaction_date’), “MMM”) }}

1 Like

@mohitchechani

can you throw more light on how to go about this like; where do i try this ??