GlideDate Functions - Scoped Application - ServiceNow

 

// Create a GlideDate object for today within the current scope
var today = new GlideDate();

// Subtract one day to get Yesterday's date
today.addDaysUTC(-1);

//Get the Formatted date in a specific format (e.g., 'yyyy-MM-dd')
var yesterdayDate = today.getByFormat('yyyy-MM-dd');

//For Testing
//yesterdayDate = '2023-10-02'
//gs.info('yesterdayDate---- '+yesterdayDate);