SanadIT
February 18, 2025, 8:03pm
1
Hi
I have pb with frappe.datetime or frappe.date in client script
I need the last day of month 6,
i used frappe.datetime.month_end (‘06-06-2025’)
But he gave me the last day of this month 2025-02-28
What to use to get 30-06-2025?
Thank you in advance
avc
February 18, 2025, 8:14pm
2
Hi @SanadIT :
frappe.datetime.month_end
always returns the end of the current month.
Try instead
moment().month('June').endOf("month").toDate()
or
moment().month(5).endOf("month").toDate()
(*) Note that month(x) is zero-based, January is 0 , so June is 5
Hope this helps.
1 Like
avc
February 19, 2025, 5:06am
4
It’s working for me.
Can you share your code?
Abdeali
February 19, 2025, 5:53am
5
Above answer is correct, but if you want date in string then do just:
moment().month(5).endOf("month").format()
Example:
1 Like
SanadIT
February 19, 2025, 12:49pm
6
moment().month(5).endOf(“month”).format()
it worked
Thank you
SanadIT
February 19, 2025, 12:52pm
7
I think the pb is not resolved with .todate()
Thank you for helps
1 Like