Hi @EdmundDelima,
Please apply the client script for it.
frappe.ui.form.on('Your DocType', {
refresh: function(frm) {
// Get the value of the your_field_name field
var dt = frm.doc.your_field_name;
// eg. var dt = 01-06-2023 (DD/MM/YYYY)
// Convert the date to the desired format
var formattedDate = frappe.datetime.str_to_user(dt);
var dateParts = formattedDate.split('-');
var Month = getMonth(dateParts[1]);
// Format the date with the month
var FormattedDate = Month + '-' + dateParts[2];
// Set the formatted date in a custom field
frm.set_value('custom_date_field', FormattedDate);
console.log("------------", FormattedDate);
// Output: JUN-2023
}
});
// Function to get the month name
function getMonth(month) {
var Months = {
'01': 'JAN',
'02': 'FEB',
'03': 'MAR',
'04': 'APR',
'05': 'MAY',
'06': 'JUN',
'07': 'JULY',
'08': 'AUG',
'09': 'SEP',
'10': 'OCT',
'11': 'NOV',
'12': 'DEC'
};
return Months[month];
}
Please set your doctype name and field name according.
Reference:
Thank You!