1

I want to retrieve data from within 60 days of a created_at date. Here are two columns: SomeValueColumn, created_at. I only want data for each row of the SomeValueColumn WHERE the created_at date is within 60 days.

What is the most efficient way of doing this? I can't seem to figure out the where statement.

2 Answers 2

1

Use the INTERVAL function:

SELECT SomeValueColumn, Created_At
FROM   YourTable
WHERE  Created_At > CURRENT_DATE - INTERVAL '60 days'
Sign up to request clarification or add additional context in comments.

Comments

0

You need a where statement like this:

DATEADD(DAY,-60,GETDATE())

So your query will look like this:

SELECT SomeValueColumn, created_at FROM table WHERE DATEADD(DAY,-60,GETDATE())

1 Comment

Oops, I didn't see the postgress tag, ignore this answer. Its for mssql

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.