Skip to content
Advertisement

Get the dates of two weeks from today from database

I have some dates in postgresql database. I want to find dates from today to next two weeks or 14 days. How i can find the dates between current date and next 14 days? This query is not working. I have date format 2019-12-26 in database.

"SELECT work_date FROM USERS_SCHEDULE WHERE user_id = 11 AND data(now() +14)";

Advertisement

Answer

SELECT work_date 
FROM users_schedule 
WHERE user_id = 11 
  AND work_date BETWEEN CURRENT_DATE
                    AND CURRENT_DATE + INTERVAL '14 days'
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement