How do I perform arithmetics on date field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2024 08:09 PM
- Hi, I have a date field which I want to write a business rule for. I have a due_date field and I want to generate reminder when it is 50% towards the due date.
- To do this I also have a reminder_date field which I want to populate with an insert business rule to calculate the reminder_date based on due_date.
- When I use GlideDateTime.subtract(), it returns undefined.
- Are there any ways to perform arithmetic operations on date fields in business rules?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2024 08:15 PM
Reference to Production API:
- addDays(Number days)
- add(GlideTime time)
Hope one of these functions can help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2024 09:09 PM
Below custom action might be useful :
Also, refer below posts :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2024 09:41 PM
Hi @Yi Ming Song ,
Before doing the subtraction can you convert the dates using getNumericValue() functions it converts the date to milliseconds and then you can simply do the subtraction no need to use the subtract function and once you have the value of the date you can set it back using setNumericValue().
Please mark helpful/correct if my response helped you.