MySQL Forums
Forum List  »  Newbie

Re: Dates between 2 dates
Posted by: laptop alias
Date: January 31, 2010 08:29AM

First you have either to build a calendar table containing the complete range of dates in which you're interested or build a table of integers (0-9) and join this onto the seed date as often as is required, e.g.:

SELECT ADDDATE('2010-01-30',INTERVAL i2.i*10+i1.i DAY) date 
  FROM ints i1
     , ints i2 
HAVING date -- or WHERE  ADDDATE('2010-01-30',INTERVAL i2.i*10+i1.i DAY)
       BETWEEN '2010-01-30' AND '2010-02-05' 
 ORDER 
    BY date;

A loop at the application level (e.g. with a bit of PHP) is another good way of doing this)

Options: ReplyQuote


Subject
Written By
Posted
January 31, 2010 06:07AM
Re: Dates between 2 dates
January 31, 2010 08:29AM
January 31, 2010 08:48AM
January 31, 2010 09:04AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.