Probably the easiest way to do date comparisons is to define the type as date, rather than as a timestamp, assuming you don't need an hour, minute, second, timezone. In an html form you can enter the date you wish to compare in the format YYYY-MM-DD and have it submitted, along with the select criteria via an html button. As a part of the process of submitting the html form, the html form submit should should call the code needed to select the record that hold the date to be compared via a SELECT statement (eg SELECT datefield FROM the_table Where primary_key = '12345'), and convert the returned value to a string variable, as normal. Then do a comparison in php to see if the submitted date in the html form equals the date retrived from postgresql table record.
Here is more about PostgreSQL dates:
http://www.postgresql.org/docs/techdocs.13
Regards,
LelandJ
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 >
©2006 Leland Jackson |