Table Specific - Date Format

shetzel
Mega Guru

Hello,

I would like to change the system level format of my dates to: yyyy-MMM-dd . BUT, when I do I break an integration script at my Company. (I'm exporting a report out of Service-now and then parsing out a date field)

I need one specific table in my instance to display the date as yyyy-MM-dd. Or convert the date back to the 'MM' format before exporting my report.

This data is flowing: Service-now (SNC) Table > SNC Database View > SNC Report > SNC Scheduled Data Extract >>> to my Company (broken script)

I would like to normalize this date field in Service-now as I don't have access to the script at my company. Any ideas?

Thanks!

4 REPLIES 4

Mark Stanger
Giga Sage

I don't have a specific solution for you, but I think you could probably create a second field on that table for the purposes of your integration that was just a string field or something. Then you could set up a business rule that runs before insert/update of records on that table and parses out the correct information from the date field to populate in the new field.


Is there any solution for this natively yet? I'm in the same situation as well. The third party I'm integrating with, will only accept date values in the format of mm/dd/yyyy and our system is set to YYYY-MM-DD.   Is there a clean way to do this? mark.stanger & Jacob.Andersen



i've tried a couple formats in my business rule but I may be missing something still..



var gd = new GlideDate();


gd.setValue('YYYY-MM-DD'); //<- think this is an issue


  return{


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


  }



&



var pd = new GlideDate();


pd.setValue('');


s.setStringParameter('u_actual_date', pd.getByFormat("MM/dd/yyyy"));


  var gdtFutureDate = new GlideDateTime('2016-10-30 00:00:00');


  strFutureDate = gdtFutureDate.getDate().getByFormat("MM/dd/yyyy");


gs.print(strFutureDate);



ctomasi


Take a look at Abhi's comment from this morning on this thread.



How to change date and time format


nice ctomasi, thanks,



why is it necessary to set an actual date on " var date_time= '2016-11-05 15:23:24'; " ? do i need to update this, i don't understand or does that date matter?



my business rule looks like,



var date_time = '2016-11-05 15:23:24';


var date = date_time.split(' ')[0];


var time = date_time.split(' ')[1];


var gd = new GlideDate();


        gd.setValue(date);


date = gd.getByFormat('MM/DD/yyyy');


date_time = date+' '+time;


s.setStringParameter('u_actual_date', gd.getByFormat("MM/DD/yyyy"));