Whats wrong with below code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 06:31 AM
Hello All,
Whats wrong with below code? I have included this in a flow variable. I am selecting Effective date as Mar 4, 2024. However the datediff is not being calculated correctly. Included a screenshot of logs as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 08:06 AM
@ankurbawisk I dont see the record in sys_trigger table. it should atleast show there..
Please note that my flow is in HR core scope. Is this something creating issue ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 08:01 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 06:57 AM - edited 02-24-2025 07:00 AM
Hi @dvelloriy
If you are working on the global scope, then you can use below script.
var diff = gs.dateDiff(current Date.getDisplayValue(),effectiveDate.getDisplayValue(),true); //This would return seconds
var days = diff/86400; //Convert the seconds to Days
If it's in scoped application, then try below code.
var currentDate = gdt.getLocalDate();
var dateDifferenceInMs = currentDate.getNumericValue() - GlideDateTime(effectiveDate).getNumericValue();
var dateDifferenceInDays = Math.floor(dateDifferenceInMs / (1000 * 60 * 60 * 24));
gs.info(dateDifferenceInDays);
Regards,
Siva