Home > Blockchain >  How to find previous weeks date?
How to find previous weeks date?

Time:09-30

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.

CodePudding user response:

No function is needed, just use data 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]
  • Related