January 14th, 2000, 11:53 AM
My database has an expireing date column
how can I select data based on current date
against expiring date, something like:
select * from $table
where ??currentdate?? >= expiredate
January 14th, 2000, 12:06 PM
Depending on the format of expiredate you can use curdate() or now().
If expiredate is a timestamp(8) then you can use this where clause:
if expiredate is a timestamp(14) then you can use
January 14th, 2000, 03:38 PM
Another example: say you have a two column table with an event name (event) and the date of that event in timestamp(8) format (event_date) and you wish to delete the events from the database that are more than 7 days old.
delete from table_name where to_days(now()) - to_days(event_date) > 7;
select event from table_name where to_days(now()) - to_days(event_date) = 7; // select last week's events
the to_days() function works on date and timestamp data types and returns the number of days since year 0 -> 1 A.D., 1 B.C. or somewhere around there
[This message has been edited by Kyuzo (edited January 14, 2000).]