开发者

Wordpress SQL: Selecting posts after a certain date

开发者 https://www.devze.com 2023-03-15 10:05 出处:网络
Having trouble with dates. What SQL code would I use to get all posts after 01.01开发者_运维知识库.2011?

Having trouble with dates. What SQL code would I use to get all posts after 01.01开发者_运维知识库.2011?

AND post_date > XXXX

Thanks in advance.


AND post_date > "2011-01-01"

http://dev.mysql.com/doc/refman/5.0/en/using-date.html


SELECT * FROM posts
WHERE post_date > '2011-01-01'
ORDER BY post_date

something like that should work, or if you want between two dates

SELECT * FROM posts
WHERE post_date BETWEEN '2011-01-01' AND '2011-02-01'
ORDER BY post_date

hope that helps

lots of good refrence here http://www.w3schools.com/sql/sql_between.asp


In MySQL it would be:

SELECT * FROM myTable WHERE post_date='2008-11-11'

In PostgreSQL it would be:

SELECT * FROM myTable WHERE post_date='2008-11-11'::date
0

精彩评论

暂无评论...
验证码 换一张
取 消