RE: OT - Getting age from MySQL

2004-02-27 Thread Barney Boisvert
Just put the _expression_ in the WHERE clause as well:

  SELECT
 Name,
 dob,
 year(current_date) - year(dob) - 
 (if(dayofyear(dob)dayofyear(current_date),1,0)) AS Age
FROM cand
 WHERE 1=1
 AND year(current_date) - year(dob) - 
 (if(dayofyear(dob)dayofyear(current_date),1,0))  1

 -Original Message-
 From: Spectrum WebDesign [mailto:[EMAIL PROTECTED] 
 Sent: Friday, February 27, 2004 10:35 AM
 To: CF-Talk
 Subject: OT - Getting age from MySQL
 
 Hi all
 
 our DB have a field with dob from our clients. I'm looking 
 for a script to calculate the age including WHERE clauses.
 
 But MySQL give an error: Unknown column Age in where clause.
 
 Please look:
 
 SELECT
 Name,
 dob,
 year(current_date) - year(dob) - 
 (if(dayofyear(dob)dayofyear(current_date),1,0)) AS Age
FROM cand
 WHERE 1=1
 AND Age  1
 
 How to do that?
 
 
 Thanx in advance
 
 
 -- 
 ___
 Sign-up for Ads Free at Mail.com
 http://promo.mail.com/adsfreejump.htm
 
 

 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: OT - Getting age from MySQL

2004-02-27 Thread Greg Luce
Providing the date functions you used in the age calculation work try:

SELECT Name, dob
FROM cand
WHERE (year(current_date) - year(dob) -
(if(dayofyear(dob)dayofyear(current_date),1,0)))  1

Let me know,
Greg

-Original Message-
From: Spectrum WebDesign [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 27, 2004 1:35 PM
To: CF-Talk
Subject: OT - Getting age from MySQL

Hi all

our DB have a field with dob from our clients. I'm looking for a script
to calculate the age including WHERE clauses.

But MySQL give an error: Unknown column Age in where clause.

Please look:

SELECT
Name,
dob,
year(current_date) - year(dob) -
(if(dayofyear(dob)dayofyear(current_date),1,0)) AS AgeFROM cand WHERE
1=1 AND Age  1

How to do that?

Thanx in advance

-- 
___
Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: OT - Getting age from MySQL

2004-02-27 Thread Spectrum WebDesign
Thanks Greg

works fine now

- Original Message -
From: Greg Luce [EMAIL PROTECTED]
Date: Fri, 27 Feb 2004 13:50:39 -0500
To: CF-Talk [EMAIL PROTECTED]
Subject: RE: OT - Getting age from MySQL

Providing the date functions you used in the age calculation work try:

SELECT Name, dob
FROM cand
WHERE (year(current_date) - year(dob) -
(if(dayofyear(dob)dayofyear(current_date),1,0)))  1

Let me know,
Greg

-Original Message-
From: Spectrum WebDesign [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 27, 2004 1:35 PM
To: CF-Talk
Subject: OT - Getting age from MySQL

Hi all

our DB have a field with dob from our clients. I'm looking for a script
to calculate the age including WHERE clauses.

But MySQL give an error: Unknown column Age in where clause.

Please look:

SELECT
Name,
dob,
year(current_date) - year(dob) -
(if(dayofyear(dob)dayofyear(current_date),1,0)) AS AgeFROM cand WHERE
1=1 AND Age  1

How to do that?

Thanx in advance

-- 
___
Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: OT - Getting age from MySQL

2004-02-27 Thread Philip Arnold
 From: Spectrum WebDesign
 
 our DB have a field with dob from our clients. I'm looking 
 for a script to calculate the age including WHERE clauses.
 
 But MySQL give an error: Unknown column Age in where clause.
 
 Please look:
 
 SELECT
 Name,
 dob,
 year(current_date) - year(dob) - 
 (if(dayofyear(dob)dayofyear(current_date),1,0)) AS AgeFROM 
 cand WHERE 1=1 AND Age  1

Aliased columns aren't usable until the query is returned

So you have to use the same calculation in the WHERE
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]