Try:
date("Y", time()) - date("Y", $date)
date("Y" works like VFP YEAR(). You may need to convert $date into a UNIX timestamp format; I'm not sure what format PostgreSQL is storing your date in.
On May 31, 2006, at 1:50 PM, Matthew Jarvis wrote:
> Matthew Jarvis wrote: >> I am having a serious brain fart today... >> All I wanna do is compare a date I've retrieved from a table to >> the current date, and if the interval is more than a year then set >> a flag so I can display it in a report. >> No problem, but I'll be darned if I can get this to work... Me >> thinks I'm confusing my PHP and Postgres... >> So if I'm running PHP code and I've got the table date stored to >> $date, then how do I do the comparison? >> mj > > Never mind... I came up with a way of doing it, but it's kinda > ugly. I'd be curious how others would do something like this... > > I'm doing this: > > //See if they are a Returning prospect (been in system > 1 yr) > $date = $row["date"]; > > $TimeSpan = date("Y-m-d", time()) - $date; > if ($TimeSpan > 1) { > etc. > > > > > > Matthew S. Jarvis > IT Manager > Bike Friday - "Performance that Packs." > www.bikefriday.com > 541/687-0487 x140 > mattj (at) bikefriday .DO.T com > > [excessive quoting removed by server]
©2006 Ted Roche |