phpbuild12;11018103 wrote:I have a database with peoples birthday stored in in a fromat of Y-m-d ( 2000-10-10 ).
The format of the date isn't nearly as important as the format of the data. In other words, is the column where you store the birthday of type DATE? That's all we need to know (since the YYYY-MM-DD representation of the date is a consequence of the proper column type, DATE, being used).
phpbuild12;11018103 wrote:I need to get each users birthday and 1 week before birthday (so I can send them an email 1 week before birthday).
Is this query going to be inside a PHP script that is executed once every day? In other words, do you actually care what the (birthday minus one week) date really is, other than answering the question "Is it today?" If not, then it sounds like you simply need to SELECT the birthday itself, and add a WHERE clause that only selects rows where the (date column minus one week) is equal to the current date.
If that's not the case, then I'd be curious as to what you're doing with the information? Regardless, you'd simply want to SELECT both the date column as well as the (date column minus one week) values. You'll probably want to alias the latter (and perhaps the former as well) to make it easier/cleaner to reference the data in PHP.