Sidebar

How can I subtract a number of days from the system date?

0 votes
512 views
asked Sep 21, 2018 by michael-h-5027 (14,350 points)

2 Answers

+1 vote

You can use the java DateUtils to add or subtract days or hours or minutes as needed. Below I'm subtracting 7 days from todays date. You can change the "-7" to whatever number of days you would like to add or subtract.

var DateUtils = org.apache.commons.lang.time.DateUtils;

var oldDate = DateUtils.addDays(qie.deduceDate(qie.getSystemDate()), -7);

var formattedOldDate = qie.formatDate('MM-dd-yyyy', oldDate  );

answered Sep 21, 2018 by michael-h-5027 (14,350 points)
edited Dec 16, 2021 by jon-t-7005
0 votes
You can also do this by following the evaluate template approach on this question: https://www.qvera.com/kb/index.php/2468
answered Jan 24, 2023 by ben-s-7515 (12,640 points)
...