Is there any way to get last day of month in jinja

I would like to show last day of current month on html file so i tried to do as below

<div style="margin-bottom: 7px;" class="text-center">
	{%= frappe.boot.letter_heads[filters.letter_head || frappe.get_doc(":Student Batch", filters.letter_head).default_letter_head || frappe.defaults.get_default("letter_head")] %}
<h2 class="text-center">{%= __("Student Monthly Attendance Sheet") %}</h2>
<h4 class="text-center">{%= ((filters.student_batch || filters.account) + "|"+filters.month+' '+filters.year)  || "" %} {%= %}</h4>
<table class="table table-bordered">
			<th style="width: 15%">{%= __("Sr No") %}</th>
			<th style="width: 15%">{%= __("Student") %}</th>
			<th style="width: 40%">{%= __("Student Name") %}</th>
			{% for(var i=0, l=data.length; i<l; i++) { %}
						<th>{%=  %}</th>
				{% } %}
			<th style="width: 15%">{%= __("Total Present") %}</th>
			<th style="width: 15%">{%= __("Total Absent") %}</th>

i am getting an error

VM180:6 Uncaught TypeError: Cannot read property 'get_last_day' of undefined(…)

i want to do this because i want to print all days of month in while taking print of report

please help me

1 Like

Don’t use

Use frappe.utils.get_last_day(date) instead.

Also, please note that the function accepts date, not month.

1 Like

I think this is because you are trying to call a python method inside a js template.
Use frappe.datetime object instead, you’ll have to implement the last day logic yourself though

1 Like

In a Jinja template, I want to extract the Year, Month and Date into separate variables from transaction_date (sales order).

For any given document, you can print the Transaction date:

{{ doc.get_formatted("transaction_date") }}

However in my case, I need each date element to fit a pre-printed paper format we have, with the date box pre-formatted. I need to print each element of the date separately. How can I extract the Year, assign to a variable, then the Month to assign to a variable, then the Day to assign to a third variable. Each variable is then printed by itself.

I have tried using datetime objects, and converting to strings using Jinja correct syntax, but no luck.

Hi there. I’d also like to use the last day of the month in an HTML print format. I tried {{frappe.utils.get_last_day('posting_date')}}

this but got an error:

ValueError: (u’Unknown string format:', ‘posting_date’)