0

I have a table that is similar to the one below. As you can see, I have stored the dates as Unix timestamps. My goal is to only return the results which are for the upcoming dates, not the ones which are in past. How can I achieve this?

id    |   date
1       1331506800 //Mar 12 2012 
2       1366149600 //Apr 17 2013
3       1413928800 //Oct 22 2014
4       1436652000 //Jul 12 2015

Desire result:

id    |   date
1       1413928800 //Oct 22 2014
2       1436652000 //Jul 12 2015

3 Answers 3

3
SELECT *
  FROM table
 WHERE date > UNIX_TIMESTAMP()
Sign up to request clarification or add additional context in comments.

4 Comments

This is the best MySQL answer.
Thanks bro! I knew you had this one!
Watch the mysql keywords! Date is also a SQL function. So you have to place the name of the column in quotes like this: SELECT * FROM table WHERE `date` > UNIX_TIMESTAMP()
1
$h->query("SELECT * FROM thetable WHERE date > " . time());

This will also work in other databases than MySQL which do not have UNIX_TIMESTAMP() function.

Comments

0

Try this::

Select * from table
where DATEDIFF(STR_TO_DATE(dateColumn, '%e %b %Y %k:%i')),now())>0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.