|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
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 ------------------ |
|
#2
|
|||
|
|||
|
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: where curdate()>=expiredate if expiredate is a timestamp(14) then you can use where now()>=expiredate |
|
#3
|
|||
|
|||
|
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; or 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).] |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > check Expire date against current date how? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|