Jump to content
km92

Selecionar entradas com mais de x dias

Recommended Posts

km92

Boa tarde.

Estou a tentar fazer um comando sql que me devolva os posts em wordpress que sejam rascunhos e que tenham mais de 5 dias, baseando-me no campo post_date do tipo datetime.

Até agora tenho este comando

SELECT * FROM wp_posts WHERE post_status like "draft" and post_type like "post"

Isto mostra-me os posts que sejam rascunhos, mas quero mostrar apenas os que tenham sido publicados há mais de 5 dias.

Existe algum comando que me permita fazer isto usando como referência um campo do tipo datetime?

Share this post


Link to post
Share on other sites
KTachyon

Qualquer coisa como:

 and post_date > DATE_SUB(NOW(), INTERVAL 5 DAY)


“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Share this post


Link to post
Share on other sites
km92

Obrigado, na verdade é

AND post_date < DATE_SUB(NOW(), INTERVAL 5 DAY)

Agora está a funcionar  :(

Share this post


Link to post
Share on other sites
KTachyon

Pois, percebi que eram "há menos de 5 dias" :(


“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.