'How to find previous weeks date?
The method should retrieve the date in the previous week that corresponds most closely to the specified date.
fromdate = prevMth(systemDateGet());
need to change the above code so that i could get the date of the previous week instead of previous month with respect to the present date.
Solution 1:[1]
No function is needed, just use date arithmetic.
systemDateGet() - 7
This will return the prior week date. This of cause implies you use a calendar with 7 day weeks.
Some additional things you may find useful:
wkOfYr(...)
dayOfWk(...)
DateTimeUtil::[VariousFunctionsHere]
Solution 2:[2]
In D365FinOps you can also use:
HcmDateTimeUtil::calculateDateWithOffset(PeriodUnit::Day,7,false)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Jeremy Caney |