mysql - Check to see if one year has passed -


i run web design firm, , sell hosting on yearly basis our customers. i'm writing ruby script read of customers mysql database , check see if year has passed. if has (or @ least close expiring), want send email them.

i have emailing part down, how check see if 1 year has passed using time class, or solution based in sql?

(looking edit, seems though don't quite know sql needed, on appreciated)

if want solve issue using ruby can use >> when dealing date increment n months (such 11, give customers time deal payment).

when you've got incremented date should compare current date see if it's less or equal (ie. date in past), if so; send out email.

>> (date.strptime('2012-07-07') >> 11).to_s => "2013-06-07" >> if (date.strptime('2011-06-15') >> 11) < datetime.now >> print "more 11 months has passed!" >> end more 11 months has passed!=> nil 

though, better of solving issue directly in sql query, boil down below:

select field1, field2, ..., fieldn `customers_table` adddate(last_payment, interval 11 months) <= () 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -