From: "Matt Warden" <[EMAIL PROTECTED]> On 6/28/05, Joseph Harris <[EMAIL PROTECTED]> wrote: > rudy and Matt, > > Thanks for the answers; I had been through that page... ;-( > > CURRENT_DATE won't work for this unless there is a way of putting > current_date -1 or -2, and I am wanting an automatic check every day for a > day ahead, which would then initiate emails. > > But this looks as though this might be the basis of what I need (from Matt's > suggestion) > > SELECT name, email > FROM foo > WHERE DAY()=2 AND MONTH()=03;
If you want names and emails for those with some date at most one day in the future, you'll want something like this: SELECT name, email FROM foo WHERE somedate <= DATE_ADD(NOW(), INTERVAL 1 DAY); If you want to make sure that old names and emails don't show up (although, this is a bit risky, as the names and emails returned depend on when you are running the script, obviously -- but the implications of this are that some emails might not get sents, and some might get sent twice, due to variations of script run time): SELECT name, email FROM foo WHERE somedate BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 1 DAY); Whatever you want to do with dates can be done using the functions listed on the date and time functions page (http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html). There's a lot there, but it's all pretty straightforward. HTH, -- Matt Warden Miami University Oxford, OH, USA http://mattwarden.com Matt, I'm following what you write, but the object is to find all names with the anniversary - probably on the following day - and that has the need to set a month and month-day for selection. I'm anticipating a list that could be in the thousands. On average each day should produce 1/365th of the list (and Feb 29 I would send on Feb 28). The original entries will include a range of years, which need to be ignored for this selection. Perhaps that bring me to selecting by DATE_FORMAT(*,%j); but that probably means setting up a temporary table with the day of the year, and then selecting all those with the day-number which matches the Month/Day. But I'm still leaning towards three fields (year, month, month-day) to make this selection easier; getting the year out of the way seems to be a problem otherwise. If I use NOW() it includes the year, and there will be no anniversary dates that recent in the database. Joseph Harris www.smilepoetryweekly.com ____ The WDVL Discussion List from WDVL.COM ____ To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or use the web interface http://e-newsletters.internet.com/discussionlists.html/ Send Your Posts To: [email protected] To change subscription settings, add a password or view the web interface: http://intm-dl.sparklist.com/read/?forum=wdvltalk ________________ http://www.wdvl.com _______________________ You are currently subscribed to wdvltalk as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.
