Current datetime minus 24 hours

Mrman
Tera Guru

Hi All,

We have a requirement to pass (current datetime minus 24 hours ) in a scheduled job .

Please see the below scheduled job   already created to call REST Message which is passing current datetime to ENDPOINT and appending some characters as per requirement .

Now we want the same characters to be passed in and need to set the REST variable as 24 hours before .

To be more precise: This scheduled job which runs daily at 1 AM EST should call REST GET method and gets the CI modified 24 hours before from current datetime.

My Scheduled job :

============

try {
var r = new sn_ws.RESTMessageV2('snQueryCIMaximo', 'get');
var dt =   gs.nowNoTZ();
var res = dt.replace(/ /g, "T");
var gt = '~gt~' + res;
r.setStringParameterNoEscape('var_date', gt);
r.setEccParameter('skip_sensor', true);

var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log("SUCCESS" + responseBody);


}
catch(ex) {
var message = ex.getMessage();
}


var script = new MaximoQueryCIUtil().populateCI(responseBody);

1 ACCEPTED SOLUTION

Nate23
Mega Guru

try:



gs.hoursAgo(24);


hoursAgo(int)

Gets a date and time for a certain number of hours ago.


Returns: The (GMT) time that was the specified number of hours ago,in the format yyyy-mm-dd hh:mm:ss.


View solution in original post

1 REPLY 1

Nate23
Mega Guru

try:



gs.hoursAgo(24);


hoursAgo(int)

Gets a date and time for a certain number of hours ago.


Returns: The (GMT) time that was the specified number of hours ago,in the format yyyy-mm-dd hh:mm:ss.