If I have a specific date of a day, how do I get the date of that day in the previous week?

Viewed 52657

SEE ANSWER FROM @Basil Bourque for most up to date answer


For example, if I have a "Date" variable "date1" with a value of (dd/mm/yyy) 03/07/2011, which is a Sunday. How do I get the "Date" of the previous Sunday "date2"? which would have the value (dd/mm/yyyy) 26/06/2011.

Is there an easy way of doing it, for example:

pseudo code:

Date date1 = (03/07/2011);
Date date2 = date1.subtractNumberOfDays(7);
4 Answers
Related