question

homestead avatar image
homestead asked

Return all content that is about to expire

I have a articles table that has a Expires column of type datetime.

How can I list all articles that will expire in the next month?

query
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Peso avatar image
Peso answered
SELECT * FROM Table1            
WHERE Expires >= dateadd(month, 1 + datediff(month, 0, getdate()), 0)            
AND Expires < dateadd(month, 2 + datediff(month, 0, getdate()), 0)            
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.