Does this help?

select
12*(year(current_date)-year('2001-03-02'))+(month(current_date)-month('2001-
03-15'));

the result is 13.

But it's quite a large query.

----- Original Message -----
From: "John Hughes" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 02, 2002 9:56 AM
Subject: [PHP-DB] figuring out number of months between two dates


> I have a table that contains a list of dates. For instance:
>
> 2001-08-23
>  2001-08-27
>  2001-09-04
> (and running through)
> 2002-06-03
>
> I want to calculate how many months between 2001-08-23 and CURRENT_DATE
> (which for discussion purposes we'll put at 2002-04-01) and how many
months
> between the first week and the last.
>
> I can count the weeks and divide by 4.333 to approximate months, but I was
> wondering if there was a way to use a PHP function or MySQL's MONTH() to
do
> the job.
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to