Hi all,
I have a notification script I want to run but only for members who sign up during a date range. The script works fine, until I try to 'automate' it using that date range. I'm using mySQL and the date added (v_submitted) col is 'DATE' type yyyy-mm-dd, auto filled with NOW() upon submission of the form.
example - the newsletter goes out on thursday every week. If you sign up between Monday of the previous week or the Sunday (prior) of that week, you get that newsletter. If you sign up later than Sunday, you get NEXT thursday's newsletter.
The logic of this seems to be (I think):
"select * from table where date of thursday minus date record added is between 4 days and 10 days" - for the first part, showing this week's new members... and:
"select * from table where date of thursday minus date record added is greater than 4" - for the second part, showing next week's new members.
SO - what I have is this (incomplete) query:
$thisweek = date("Y-m-d" , (strtotime($v_submitted) - (60*60*24*4 /* number of days in seconds */)));
$result = mysql_query(sprintf("SELECT * FROM a_mails WHERE $thisweek between 4 and 10"));
while (list($v_id, $v_name, $v_email, $v_submitted) = mysql_fetch_row($result)) {
I know it's not quite there - I'm at a loss. Can someone please point me towards the solution here? I think I may need to determine the yyyy-mm-dd of Thursday, but that seems like a pretty complicated thing to do for what I want to acheive...
thanks for any suggestions.