I can't get around how to do this in my head. I am creating a website where events can be added. I am wanting to display the upcoming events, however I am thinking of this scenario. I have events in the table which have already gone, however using the 'ORDER BY `date`' would show the events that have past still. How would I be able to do this? Would I need to use NOW() and convert the date to a time stamp?
Thanks,
Joe.
Event Dates
Event Dates
One life, live it
-
- Posts: 534
- Joined: Thu May 05, 2011 8:19 pm
Re: Event Dates
You could always have a 'past_event' and whenever the end time of the date has passed, change it to a 1 with a CRON job, then when you are displaying upcoming events, just add AND past_event = 0 to your mysql query.
I don't like to brag, but I wasn't circumcised. I was circumnavigated.
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Re: Event Dates
You will need to do some date calculation and I'm not sure if MySQL is capable of doing so with the DATETIME data type. When using a UNIX TIMESTAMP it's easier to do as you can just add something like
WHERE 'timestamp` > UNIX_TIMESTAMP(NOW())
Re: Event Dates
Thanks. I had an idea of how to use, because I had a similar scenario to this in my coursework for A level ICT. That was using Microsoft Access though Think it was something like <date() or something in that case. I just didn't know how to do it in SQL.
Thanks for your time.
Thanks for your time.
One life, live it