Checking a record is due based on the 'occuring' field

Posted by andy on Programmers See other posts from Programmers or by andy
Published on 2013-10-04T08:42:35Z Indexed on 2013/11/03 22:16 UTC
Read the original article Hit count: 180

Filed under:

I have records that have dates against them and an occurring field that contains none,yearly and monthly

id    status    note   date        last_updated   occurring
1     open      ---    01/01/2011  01/02/2010     yearly
2     open      ---    05/05/2011  03/05/2011     monthly
3     open      ---    06/06/2011  05/06/2011     none

Now I need to be able to check if a record is due (the date set has passed) which works perfect if occurring is set to none but I'm unsure of how to approach it when it's set to yearly or monthly (IE: This day in the year/month has passed)

So with the above records, if I had a method on the record called due? providing the status is 'open' it needs to return true every year when it's passed that date if it's not been updated within the year yet.

I apologise if this is confusing but it's melting my brain just trying to think of it, let alone put it into words.

© Programmers or respective owner

Related posts about date-format