How to compare current date & time with sys_updated_on?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 07:36 AM - edited 11-02-2022 07:37 AM
Hi All,
How can I compare current date & time with sys_updated_on? My requirement is to check whether the record was update recently or not.
TIA
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 08:08 AM
Hi @Ankita9
You can code using below code:
var updateDT = new GlideDateTime('sys_updated_on');
var currentDT= new GlideDateTime();
var diff = GlideDateTime.subtract(date1, date2);
gs.info(diff.getDisplayValue());
In this code, diff will store the duration between the dates so based on your requirement you can check if it was less than 1 day or 2 days or 1 week etc according to your definition of updated recently.
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023