I need help, how can I convert date format from YYYY-MM-DD to MM/DD/YYYY?

paul971
Mega Expert

Hi All --

I need some help. I cannot find a way to change my date format from sys to what is accepted by my integration. My customer only accepts mm/dd/yyyy but the system sets the date field as yyyy-mm-dd. This is within a scoped app, I do not and cannot affect global properties due to our other projects.

Is there any way i can do this, maybe just for this field in particular that is sent for the integration? Can I change a sys property for a scoped app?

thanks in advance

1 ACCEPTED SOLUTION

  var gd = new GlideDate();


  gd.setValue('2015-01-01');


  return{


  s.setStringParameter('u_actual_date', gd.getByFormat("MM/dd/yyyy")); //value of actual date


  }



View solution in original post

11 REPLIES 11

HugoFirst
Kilo Sage

Would this work?


Under System Properties


Click on System


In the resulting page, change the value of the Date format setting to mm/dd/yyyy



Try this in a sub-prod instance first.


that would change it system wide, i cannot affect other projects with this change


Abhinay Erra
Giga Sage

Use GlideDate API for this. There is a gerByFormat() method where you can convert it to the format you want


http://wiki.servicenow.com/index.php?title=Scoped_GlideDate_API_Reference#getByFormat.28String_forma...



var gd = new GlideDate();


gd.setValue('2015-01-01');


gs.info(gd.getByFormat("MM/dd/yyyy"));


Thanks abhi_r. I'm not sure where to plug this in. Can I use my business rule that is already working that is transferring the fields from the wsdl? right now, i have the date hardcoded...