Solved

# Dates calculation

Posted on 2007-12-04

Hi experts:

Im having trouble trying to calculate MonthBegin and MonthToDate.

For this task Im always looking at the previous week, if the previous week has two months in it then:

MB = The 1st of the current month

MTD = Last Sunday of the current week

else

MB = The 1st of last month.

MTD = Last Sunday of the previous week

Example:

If I run it on 2007-11-07 then

MB = 2007-11-01 and MTD = 2007-11-04

If I run it on 2007-08-01 then

MB = 2007-07-01 and MTD = 2007-07-29

I keep trying and trying but not going anywhere, will really appreciate any help or tips!

Thanks

Isaac