OTECTED]>
To: "Jesse" <[EMAIL PROTECTED]>
Cc: "MySQL List"
Sent: Wednesday, December 28, 2005 1:48 PM
Subject: Re: Need Help Writing a Trigger
Jesse,
>BTW, is there a way to change this function so that it does away with the
>"today" variable, and use
that table
instead?
Thanks,
Jesse
- Original Message - From: "Peter Brawley"
<[EMAIL PROTECTED]>
To: "Jesse" <[EMAIL PROTECTED]>
Cc: "MySQL List"
Sent: Wednesday, December 28, 2005 10:20 AM
Subject: Re: Need Help Writing a Trigger
Jesse,
>T
le instead?
Thanks,
Jesse
- Original Message -
From: "Peter Brawley" <[EMAIL PROTECTED]>
To: "Jesse" <[EMAIL PROTECTED]>
Cc: "MySQL List"
Sent: Wednesday, December 28, 2005 10:20 AM
Subject: Re: Need Help Writing a Trigger
Jesse,
>Ther
Jesse,
>Therefore, instead of putting that long calculation in my query every
time,
>I'm looking for a simpler solution, a more automatic one.
CREATE FUNCTION Age( dob DATE, today DATE ) RETURNS INTEGER
DETERMINISTIC
BEGIN
RETURN DATE_FORMAT(FROM_DAYS(TO_DAYS(today) - TO_DAYS(dob)), '%Y') + 0
It's not as simple as that. First, if you subtract the curdate() from the
birthday (or vice versa), you end up with some large number that isn't the
actual age at all. So, the calculation is a bit more complicated than that.
Also, I'm not interested in their current age, but their age at the t
On Tuesday 27 December 2005 2:34 pm, Jesse wrote:
> I'm trying to write a trigger that will update the age of a camper when
> ever a record is updated or inserted. I have a table named Campers which
> contains basic information about the camper as well as their birthday. I
> have another table na