#!/bin/sh
dbname="birthday"
dbhost="localhost"
dbuser="alpha"
dbpass="beta"
persons=`mysql -h$dbhost -u$dbuser -p$dbpass $dbname --execute="select email from dates where date_format(adddate(now(), interval 1 day), \"%d %M\") = birthday" | grep -v ^date_format`
if [ "$persons" != "" ]; then
echo $persons | while read email; do
echo "Wish you all the best" | /bin/mail -s "Happy Birthday" "$email"
done
fi
regards,
Patrascu Eugeniu wrote:
Hi,
I have a problem calculating birthdays in sql. Here goes my setup:
I have a database that contains the bithdays of a number of people, and I want to know when there birthday is to congratulate them.
The thing is that I want to now that a day before their birthday. Therefore I need a way to do that, and I do not know how to do it, so I am asking on this list, maybe there is someone that can tell me how.
Regards,
Patrascu Eugeniu
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
-- George Chelidze
--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php