- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2021 01:07 AM
Hi,
How to change date format from YYYY-MM-DD to Month DD, YYYY (for instance May 07, 2021)?
script include function
getEmployeeDate: function() {
var grHRProfile= new GlideRecord('sn_hr_core_profile');
grHRProfile.addQuery('user', gs.getUserID());
grHRProfile.query();
if (grHRProfile.next()) {
var hrProfileData = {
employment_end_date: grHRProfile.getValue('employment_end_date'),
probation_end_date: grHRProfile.getValue('probation_end_date')
}
return JSON.stringify(hrProfileData);
}
I found similar solution but it's implemented in calculated value
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2021 05:34 AM
Hi Try this
getEmployeeDate: function() {
var grHRProfile = new GlideRecord('sn_hr_core_profile');
grHRProfile.addQuery('user', gs.getUserID());
grHRProfile.query();
if (grHRProfile.next()) {
var gdt = new GlideDate();
gdt.setDisplayValue(grHRProfile.getValue('employment_end_date'));
var endDate = gdt.getByFormat("MMMM dd,YYYY");
var gdt1 = new GlideDate();
gdt1.setDisplayValue(grHRProfile.getValue('probation_end_date'));
var probDate = gdt1.getByFormat("MMMM dd,YYYY");
var hrProfileData = {
employment_end_date: endDate,
probation_end_date: probDate,
};
return JSON.stringify(hrProfileData);
}
Thank you
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2021 01:28 AM
Hello Kris,
var currentdate = new GlideDate();
var cdt = currentdate.getByFormat("MM-dd-YYYY"); // Use This format
return adt;
I hope this will help you.
Mark ✅ Correct if this solves your issue and also mark ???? Helpful if applicable
Regards,
Saurabh,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2021 01:35 AM
Hi @kris
Try this
getEmployeeDate: function() {
var grHRProfile= new GlideRecord('sn_hr_core_profile');
grHRProfile.addQuery('user', gs.getUserID());
grHRProfile.query();
var gdt = new GlideDate();
gdt.setDisplayValue('2022-08-31');
gdt.getByFormat("MMMM dd,YYYY");
var gdt = new GlideDate();
gdt.setDisplayValue(grHRProfile.getValue('employment_end_date'));
var empenddate = gdt.getByFormat("MMMM dd,YYYY");
var gdt1 = new GlideDate();
gdt1.setDisplayValue(grHRProfile.getValue('probation_end_date'));
var probenddate = gdt.getByFormat("MMMM dd,YYYY");
if (grHRProfile.next()) {
var hrProfileData = {
employment_end_date: empenddate,
probation_end_date: probenddate
}
return JSON.stringify(hrProfileData);
}
Hope this helps
Thank you
Prasad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2021 04:28 AM
Hi @kris
getEmployeeDate: function() {
var grHRProfile= new GlideRecord('sn_hr_core_profile');
grHRProfile.addQuery('user', gs.getUserID());
grHRProfile.query();
var gdt = new GlideDate();
gdt.setDisplayValue(grHRProfile.getValue('employment_end_date'));
var empenddate = gdt.getByFormat("MMMM dd,YYYY");
var gdt1 = new GlideDate();
gdt1.setDisplayValue(grHRProfile.getValue('probation_end_date'));
var probenddate = gdt.getByFormat("MMMM dd,YYYY");
if (grHRProfile.next()) {
var hrProfileData = {
employment_end_date: empenddate,
probation_end_date: probenddate
}
return JSON.stringify(hrProfileData);
}
Did you get chance to check my answer?
Just curious to know if your issue is resolved now.
If yes, can you please mark appropriate response as correct for others who may have a similar question in the future and close this unresolved thread.
If not, please let us know if you need any other help
Thank you
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2021 05:25 AM
Hi
I did as you mentioned but it doesn't work.
endDate and probDate are empty
getEmployeeDate: function() {
var grHRProfile = new GlideRecord('sn_hr_core_profile');
grHRProfile.addQuery('user', gs.getUserID());
grHRProfile.query();
var gdt = new GlideDate();
gdt.setDisplayValue(grHRProfile.getValue('employment_end_date'));
var endDate = gdt.getByFormat("MMMM dd,YYYY");
var gdt1 = new GlideDate();
gdt1.setDisplayValue(grHRProfile.getValue('probation_end_date'));
var probDate = gdt1.getByFormat("MMMM dd,YYYY");
if (grHRProfile.next()) {
var hrProfileData = {
employment_end_date: endDate,
u_pfe_z_servicedate: probDate,
};
return JSON.stringify(hrProfileData);
}