I want to change the date format for Printing. Ian getting the date from another doc in print itself.
{{ frappe.db.get_value(“Batch”, items.batch_number, “expiry_date”) }}
I want this date to be print in format strftime('%b %Y’) but this is not working.
Please let me know how to format this date.
@SLS_Admin,
please check Changing Date Format
Thanks, Makarand
But how to use those with get_value, as I am getting the date from another doc in Print Itself.
@SLS_Admin,
try,
{{ frappe.utils.formatdate(frappe.db.get_value("Batch", items.batch_number, "expiry_date"), "dateformat") }}
Or you can add the custom field in items table and fetch the expiry_date
on item_code
trigger instead of fetching expiry_date
in print format and access the custom field in print format.
Thanks, Makarand
This works but it give me the date as MM-yyyy. What will be the “date format” if I want Apr 2018 instead of 04-2018
@SLS_Admin,
try replacing "dateformat"
by "MMM yyyy"
Frappe uses the babel utilities for datetime formats please check babel for detail date formats.
Thanks, Makarand
1 Like
Got it. Thanks for such a prompt reply.