( Date field) Converting Seconds into days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2019 06:59 AM
Hi All,
I Have one date field named as date1 and i need to differentiate this date1 field with current date.
var diff= gs.diff(date1.getDisplayValue(),gs.now().getDisplayValue(),true) ---- Now i need to convert these seconds into days.
var days=parseInt((diff/(60*60*24)));
But not working as expected, it showing one day delay to expected day.
Can any one help.
Thanks,
Aahitha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2019 07:13 AM
Hi,
It is a date field and not date/time field.
Can you tell for example what date are you comparing?
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2019 07:23 AM
an example of dateDiff that may help:
var date1 = new GlideDateTime();
var date2 = new GlideDateTime();
date1.setDisplayValueInternal('2014-01-01 12:00:00');
date2.setDisplayValueInternal('2014-01-03 12:00:00');
var diffDays = gs.dateDiff(date1.getDisplayValue(), date2.getDisplayValue(), true);
gs.info(diffDays/(60*60*24)