birthday calculation problem

2002-12-27 Thread Patrascu Eugeniu
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



Re: birthday calculation problem

2002-12-27 Thread George Chelidze
Not tested. You should have table dates with columns email and 
birthday. birthday is in format 27 December

#!/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




Re: birthday calculation problem

2002-12-27 Thread Gelu Gogancea
Hi,
I think you can try to use TO_DAYS() function;
eg:
select TO_DAYS('2002-12-28')-TO_DAYS(NOW());

Regards,

Gelu
_
G.NET SOFTWARE COMPANY

Permanent e-mail address : [EMAIL PROTECTED]
  [EMAIL PROTECTED]
- Original Message -
From: Patrascu Eugeniu [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, December 27, 2002 2:56 PM
Subject: birthday calculation problem


 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




-
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




Re: birthday calculation problem

2002-12-27 Thread Gelu Gogancea
Hi,
I think you can try to use TO_DAYS() function;
eg:
select TO_DAYS('2002-12-28')-TO_DAYS(NOW());

Regards,

Gelu
_
G.NET SOFTWARE COMPANY

Permanent e-mail address : [EMAIL PROTECTED]
  [EMAIL PROTECTED]
- Original Message -
From: Patrascu Eugeniu [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, December 27, 2002 2:56 PM
Subject: birthday calculation problem


 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




-
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




Re: birthday calculation problem

2002-12-27 Thread Paul DuBois
At 14:56 +0200 12/27/02, 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.


Compare the MONTH() and DAYOFMONTH() values of your birthday column
to the MONTH() and DAYOFMONTH() values for tomorrow's date, which you
can calculate using CURDATE() and DATE_ADD().  Something like this:

SET @tomorrow = DATE_ADD(CURDATE(),INTERVAL 1 DAY);

SELECT * FROM tbl_name
WHERE MONTH(birth) = MONTH(@tomorrow)
AND DAYOFMONTH(birth) = DAYOFMONTH(@tomorrow);





Regards,

Patrascu Eugeniu



sql, query

-
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