First day of the current month

Hi community,

A very quick question here. Is there any function to get the first day of the current month (like sys_defaults.year_start_date for the 1st of January).

I need that to set the default value of a filter in a report (cf. code below).

frappe.query_reports["Entrepreneurs Performances"] = {        
    "filters": [
            {
                    "fieldname":"from_date",
                    "label": __("From Date"),
                    "fieldtype": "Date",
                    "width": "80",
                    "default": ????,
            },
            {
                    "fieldname":"to_date",
                    "label": __("To Date"),
                    "fieldtype": "Date",
                    "width": "80",
                    "default": frappe.datetime.get_today()
            }
    ]

}

Thank for your help :smile:

1 Like

I did:

var d = new Date();
....
"default": new Date(d.getFullYear(),d.getMonth(),1),

I works perfectly. Sorry for this useless post.

5 Likes