Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get the date and time one hour before the time of sys_created_on

Mi1
Tera Contributor

Hi,

need to get the date and time one hour before the time of "sys_created_on" that exists in every table.

now

2020-06-01 08:00:00

display

2020-06-01 07:00:00

Is it feasible?

 

Regards,

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hey,

Absolutely yes.

You can use this script as a basis and you can test using bg script:

var date = new GlideDateTime("2020-06-01 08:00:00");
gs.info(date.getValue());
date.addSeconds(-3600);
gs.info(date.getValue());

 

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

View solution in original post

2 REPLIES 2

Aman Kumar S
Kilo Patron

Hey,

Absolutely yes.

You can use this script as a basis and you can test using bg script:

var date = new GlideDateTime("2020-06-01 08:00:00");
gs.info(date.getValue());
date.addSeconds(-3600);
gs.info(date.getValue());

 

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

Mi1
Tera Contributor

Hi,

Thank you.

I worked it!

Regards,