MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old January 14th, 2000, 11:53 AM
Martijn Martijn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Posts: 14 Martijn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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


------------------

Reply With Quote
  #2  
Old January 14th, 2000, 12:06 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
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

Reply With Quote
  #3  
Old January 14th, 2000, 03:38 PM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > check Expire date against current date how?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway