Calling custom script from html

I need this simple help.

I want to Calculate difference between two dates in Quotation form

I write Custom JS as follows

function days_between(date1, date2)

// The number of milliseconds in one day
var ONE_DAY = 1000 * 60 * 60 * 24

// Convert both dates to milliseconds
var date1_ms = date1.getTime()
var date2_ms = date2.getTime()

// Calculate the difference in milliseconds
var difference_ms = Math.abs(date1_ms - date2_ms)

// Convert back to days and return
return Math.round(difference_ms/ONE_DAY)


I want to calculate days_difference(doc.upto,doc.transaction_date) . Both dates are already in my Quotation form. What should I write access those jinja template for printing.
I tried:
Remaining Days: {{ days_difference( {{ doc.get.formatted(" doc.upto ") }} , {{ doc.get.formatted(“doc.transaction_date” )}} ) }}

But It shows nothing.

Let me suggest where should I modify and what should be done. ( Urgent )

Hi are you setting up a client or server print template?
as I understand Javascript only works on clientside scripts

@mkafle_Se follow this How to get today date

1 Like

Thank you. Job done.