How to change the date format (YYYY,MM,DD) to (DD,MM,YYYY) in the case fom.

poornima batchu
Tera Expert

HI,

I created a date field in the hr case form but the default format is (YYYY, MM, DD) this I want to change the format of my field only to (DD,MM, YYYY).Please add the possible solutions to achieve this.

Thank youfind_real_file.png

16 REPLIES 16

Harish KM
Kilo Patron
Kilo Patron

Hi if you do that it will impact to all the date fields in the system. 

Refer here

https://community.servicenow.com/community?id=community_question&sys_id=e51e9e3b1bc50450a59033f2cd4bcb68

Regards
Harish

Mohith Devatte
Tera Sage
Tera Sage

Hello,

If you do this , it will be effected across the instance.But anyhow if you want to change the format and if you are okay with changing the date format for fields across the instance please  follow below steps 

1) Open sys_properties table

2) search for this property named as "glide.sys.date_format"

3)Change the format according to your requirement from yyyy-MM-dd --> dd-MM-yyyy in value field 

 

OR  --> Follow below process for work around 

I have a work around for it 

 please follow below steps

  • Create a New Field called 'Date' of type String
  • Click 'Advanced View'

find_real_file.png

  • On 'Calculated Value' tab, check 'Calculated'

find_real_file.png

  • Insert the code below into the 'Calculation' field, substituting  with your field back end name
(function calculateLongDate(current) {
	var gDateTime = new GlideDateTime(current.u_date.getDisplayValue()); //  repalce with backend name of old created  field with type date 
    var gDate = gDateTime.getDate();
	var dt = gDate.getByFormat('dd/MM/yyyy');
	return dt; 
})(current);
  • Add your field on to the form below Date field and observe the format

Please accept this solution if it helped you some or the other way

it is not working.find_real_file.png

Please try to give some value in the Date filed which you created earlier and then save the form and see the value 

And make sure you have replaced the old field name in the above script that i pasted 

(function calculateLongDate(current) {
	var gDateTime = new GlideDateTime(current.u_date.getDisplayValue()); //  repalce with backend name of old created  field back end name with type date 
    var gDate = gDateTime.getDate();
	var dt = gDate.getByFormat('dd/MM/yyyy');
	return dt; 
})(current);

Updated for your reference again

find_real_file.png