how to change the date type field from yyyy-mm-dd to dd/mm/yyyy for a particular field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 02:13 AM
how to change the date type field format from yyyy-mm-dd to dd/mm/yyyy for a particular field on a particular table without changing system properties or without changing the field type to string?
Here in this scenario, I want payment reference field to display in dd/mm/yyyy format, payment reference is a date field?
already tried date.getbyformat its only changing string field, but not helping with the date field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 08:53 AM
Hi @avi_hb ,
You can create a on change client script like below
var ga = new GlideAjax('PGIncidentAJAX');
ga.addParam('sysparm_name', 'getGMT');
ga.addParam('sysparm_date_time', newValue);
ga.getXML(processResponse);
function processResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('payment_reference', answer);
}
And a script include similar to below
var PGIncidentAJAX = Class.create();
PGIncidentAJAX.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGMT: function(){
var dt = this.getParameter('sysparm_date_time');
var gdt = new GlideDateTime();
gdt.setDisplayValue(dt);
var date = gdt.getValue().split(' ');
var dateonly = new GlideDate();
dateonly.setValue(date[0]);
var last = dateonly.getByFormat('dd/MM/yyyy') + " " + date[1];
return last;
},
type: 'PGIncidentAJAX'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 08:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2023 04:10 AM
Manmohan, I want to display the date in dd/mm/yyyy format for a DATE FIELD, as mentioned above, in the example for which the link you have shared its for the string field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2023 04:13 AM
@Mike Patel , @Chuck Tomasi Can you please help me with this requirement?