- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2020 03:24 AM
Hello,
I have a script in business rule that gets the value of recipients of an email. There are emails that has many recipients.
I want to check if the recipients start date is in between the created and updated date of my custom table. And if not then they should not be included in my output.
All dates are in date/time type.
Is there a way to do this?
Thank you.
Appreciate all the help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2020 04:11 AM
Something like this
var createdDate = new GlideDateTime(<createdTime>);
var updatedTime = new GlideDateTime(<updatedTime>);
var startDate = new GlideDateTime(<startDate>);
if(startDate.getNumericValue() < updatedTime.getNumericValue() && startDate.getNumericValue() > createdDate.getNumericValue()){
// within
}
else{
// outside date
}
Regards
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
‎12-04-2020 03:43 AM
Hi Evren,
you can use this :
https://developer.servicenow.com/dev.do#!/reference/api/paris/server_legacy/c_GlideDateTimeAPI#r_GDT-compareTo_O
P.S. I assume you have to use 3 dates - the initial occurence date A, the allowed date B and the responce date C. So you need to add B to A = AB and then compare to C. Is that so or I am not following?
Cheers,
Joro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2020 04:01 AM
Hello,
dateA - start_date
dateB - end_date
dateC - created_date
I need to check if dateC is in between dateA and dateB.
Now, that's not all. Every recipient on the list has different created date.
Let's say the outputs are:
1st recipient - dateC is between dateA and dateB
2nd recipient - dateC is not between dateA and dateB
I need to get the data of the 1st recipient only since it's the only one where the condition ended up true.
I'm sorry if my explanation is confusing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2020 04:11 AM
Something like this
var createdDate = new GlideDateTime(<createdTime>);
var updatedTime = new GlideDateTime(<updatedTime>);
var startDate = new GlideDateTime(<startDate>);
if(startDate.getNumericValue() < updatedTime.getNumericValue() && startDate.getNumericValue() > createdDate.getNumericValue()){
// within
}
else{
// outside date
}
Regards
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
‎12-05-2020 05:36 AM
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader