Any ideas please
- Write tests - lots of them. Dates are tricky, illogical things (months have varying numbers of days, timezones affect what the current date is, remember about leap years, etc.).
- Construct an algorithm to produce the desired output.
- Code up the algorithm.
- Run the tests and adjust the code and/or algorithm until they all pass.
Which specific part of all this are you having trouble with?