How to convert date format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2014 05:45 AM
Hello all,
I have an inbound action which reads content of the email and populates a table with the information from the email body.
My issues is that the email contains long format date e.g. 24th March 2014 at 23:59hrs and I need to convert this to short format dd/mm/yyyy so it can populate date field on the form.
Appreciate any help with this.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2017 11:24 PM
Thanks Shishir...but I was wondering if I could leverage the system property glide.sys.date_format in my script include to make sure the format getting returned is dd/MM/yyyy. Any ideas?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2017 11:28 PM
You can not leverage the system property glide.sys.date_format in script include but you can try formatting the date in that way and check.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2017 11:34 PM
Naa mate, didn't work..used this below, but no luck...
gd.setValue(gdt.getValue()); //set value of GlideDate variable from the
GlideDateTime variable. Used this as I had to add months to a date field
depending on a client selected value
gd.getByFormat("dd/MM/yyyy");
return gd;
On Fri, Jun 2, 2017 at 4:28 PM, explorenow <

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2017 12:04 AM
Hi Suhas,
I have tried in this way and it's working for me, you can also try and see if works for you as well,
Changed the date format in system properties -> system
then select the Date format in User profile as the below
Please have the below code.
Client Script:
function onLoad() {
var dFormat = g_user_date_format;
var tdayDate = formatDate(new Date(),dFormat);
g_form.setValue('u_newdate', tdayDate);
var ajax = new GlideAjax('MyNeededDateBy');
ajax.addParam('sysparm_name', 'neededByDateTime');
ajax.getXML(function () {
var neededDate = ajax.getAnswer();
g_form.setValue('u_mydate', neededDate);
});
}
Script Include:
var MyNeededDateBy = Class.create();
MyNeededDateBy.prototype = Object.extendsObject(AbstractAjaxProcessor, {
neededByDateTime: function () {
var neededDate = gs.nowDateTime();
var gdt = new GlideDateTime(neededDate);
gdt.setDisplayValue(neededDate, "dd/MM/yyyy hh:mm:ss");
return gdt.getDisplayValue();
},
type: 'MyNeededDateBy'
});
Output:
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2017 01:04 AM
Thanks mate, but for setting the date field format the value returns from a
script include. And new date () instantiates today's date... Tried using
the value from script include, didn't work.
On 2 Jun 2017 5:05 PM, "explorenow" <community-no-reply@servicenow.com>