Ah, good idea. That should resolve my issue.

Thanks!
Zach

-----Original Message-----
From: Carsten H. Pedersen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 15, 2001 2:08 PM
To: Zach Curtis; [EMAIL PROTECTED]
Subject: RE: Calculating Age


> I am trying to calculate an approximate age from a birth month field
> (birthMonthVal TINYINT(3) UNSIGNED NOT NULL) and birth year field
> (birthYearVal SMALLINT(4) UNSIGNED NOT NULL). I do not have the day so an
> approximate age is OK (the results will be grouped in an aggregate format
> anyway).
> 
> How do I...
> A) bring these two fields together
> B) assign a day value to calculate age, if needed
> C) calculate the age
> 
> I was trying something like the following syntax but this doesn't combine
> the fields or use a date format.
> SELECT (TO_DAYS(NOW())-TO_DAYS(???)/365) FROM table;

Why not simply use a DATE field and just set the day
of month to 1? That will make all your calculations
much easier.

/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq




---------------------------------------------------------------------
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

Reply via email to