If anyone is interested, this is what I finally came up with. I'm not sure
how graceful it is, but it works ;) 

<?

$quarter = ceil(date('n')/3);

if ($quarter = 1)
        {
                $period_first_day = date("Y-m-d",
mktime(0,0,0,10,1,date(Y)-1));
                $period_last_day = date("Y-m-d",
mktime(0,0,0,12,31,date(Y)-1));
        }

elseif ($quarter = 2)
        {
                $period_first_day = date("Y-m-d",
mktime(0,0,0,1,1,date(Y)));
                $period_last_day = date("Y-m-d",
mktime(0,0,0,3,31,date(Y)));
        }

elseif ($quarter = 3)
        {
                $period_first_day = date("Y-m-d",
mktime(0,0,0,4,1,date(Y)));
                $period_last_day = date("Y-m-d",
mktime(0,0,0,6,30,date(Y)));
        }

elseif ($quarter = 4)
        {
                $period_first_day = date("Y-m-d",
mktime(0,0,0,7,1,date(Y)));
                $period_last_day = date("Y-m-d",
mktime(0,0,0,9,30,date(Y)));
        }

echo "Start of Period: $period_first_day<br>";
echo "End of Period: $period_last_day";

?>


-----Original Message-----
From: Rankin, Randy [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 19, 2002 8:57 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Determine last quarter


Hello all,

Does anyone know how I might determine the start date and end date of the
previous calendar quarter based on today's date. For example, today is
2002-03-19, so the previous quarter start date would return 2001-10-01 and
the previous quarter end date would return 2001-12-31. I am trying to
determine these dates for a report that generates previous quarter sales
based on today (whatever 'today' might be). Hope that's clear. 

Thanks in advance,

Randy Rankin

Reply via email to