0

I have a db table that has the following structure: id (auto increment), title (varchar 255), datetime (datetime format)

I am trying to get all articles in the future, eg after current timestamp - would the query below look right? I have one row that has a datetime of 2012-01-19 10:02:20 so cannot understand why this isn't being shown in the results?

SELECT *, UNIX_TIMESTAMP(datetime) AS end_dateStamp 
FROM (`news`) WHERE UNIX_TIMESTAMP(`datetime`) > 1326991924

2 Answers 2

2

Try this:

SELECT *, UNIX_TIMESTAMP(datetime) AS end_dateStamp 
FROM `news` 
WHERE `datetime` > NOW()
Sign up to request clarification or add additional context in comments.

Comments

2

You can simply use mysql's NOW() function:

SELECT *, UNIX_TIMESTAMP(datetime) AS end_dateStamp 
FROM (`news`) WHERE `datetime` > NOW()

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.