#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Norcross, GA
    Posts
    458
    Rep Power
    18
    WHERE TO_DAYS(eventdate) > TO_DAYS(NOW())

    This is what I currently have. Works great. Now I'd like to narrow the focus to show only future eventdates that occur in the next 60 days.

    Just fooling around I tried:
    WHERE TO_DAYS(eventdate) > TO_DAYS(NOW()) +60

    That returned everything in the future starting 60 days from NOW().

    Looked at the MySQL documentation and there wasn't an example to demostrate this concept, so I'm not even sure it can be done.

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2001
    Posts
    1,481
    Rep Power
    18
    Hi,

    Don't limit yourself to just that date/time function. Mysql has so many date/time functions that you can do virtually anything. In particular, you might be interested in the DATE_ADD function. Check out how this works at http://www.mysql.com and check through all the date/time functions to see if you find something you like better. Also, this thread might be insightful:

    date troubles in PHP/MySQL

    Lol...I just realized what you said above? Are you kidding? You said your SELECT statement returns everything starting 60 days in the future and beyond, but you want everything less than 60 days in the future? How about this:

    WHERE TO_DAYS(eventdate) <= TO_DAYS(NOW()) +60

    By the way, mysql can compare date types without converting them to seconds or days. This should work too:

    SELECT eventdate FROM mytable WHERE eventdate <= DATE_ADD(NOW(), INTERVAL 60 DAY)

    [Edited by 7stud on 03-22-2001 at 09:18 AM]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Norcross, GA
    Posts
    458
    Rep Power
    18
    No dice. Neither of your examples work.

    Anyone else?
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    22
    where to_days(eventdate) BETWEEN to_days(now()) AND (to_days(now())+60)
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2001
    Posts
    1,481
    Rep Power
    18
    lol......you have these two statements right?

    WHERE TO_DAYS(eventdate) > TO_DAYS(NOW())

    and

    WHERE TO_DAYS(eventdate) > TO_DAYS(NOW()) +60
    (but this gives you the opposite of what you want, so flip the inequality sign around)


    So, combining those statements gives you:

    WHERE TO_DAYS(eventday) > TO_DAYS(NOW())
    AND TO_DAYS(eventday) <=TO_DAYS(NOW()) + 60

    or, simplifying:

    WHERE eventday > CURDATE()
    AND eventday <= CURDATE() + 60

    too funny.

IMN logo majestic logo threadwatch logo seochat tools logo