1

I'm wanting to change the mySQL request to ask for all events in the database from today onward. Right now it is just asking for all events only on thdays date. This is what I have:

  $query  =  "SELECT * FROM events WHERE date(convert_tz(StartDate,'+00:00','". $numric_time."'))='$currentDate' AND UserID='" . $_SESSION['userData']['UserID'] ."' ORDER BY StartTime"; //getting date's agendas

Thanks!

fedorqui
  • 275,237
  • 103
  • 548
  • 598
Joel
  • 2,691
  • 7
  • 40
  • 72

1 Answers1

1
SELECT *
FROM events
WHERE StartDate >= CURDATE()
    AND...

If you need the timezone offset, change the query to use CURDATE() +/- INTERVAL x HOUR, wrapping the StartDate in a function such as CONVERT_TZ causes MySql not to use any index on that column.

The Scrum Meister
  • 29,681
  • 8
  • 66
  • 64
  • I do need that timezone offset. Can you explain how it will look while keeping the timezone stuff there? I'm a newbie. Thanks! – Joel Apr 06 '11 at 05:25
  • @joel If you are able to get a numeric offset instead of a formatted string (for example `2` instead of `+2:00`) the query would look like: `WHERE StartData >= CURDATE() - INTERVAL 2 HOUR` – The Scrum Meister Apr 06 '11 at 05:29
  • hmm. I'm not sure if I'm able to do that, as I believe that variable is used elsewhere in the code for other things. – Joel Apr 06 '11 at 06:06