How to get current date - two weeks date using Postgresql?

14,280
SELECT now() - interval '2 week';

This works just fine. What is the exact error you are getting?

Since you are not pulling any data from table test_base there is no need to include that in a FROM clause.

Share:
14,280
AKIWEB
Author by

AKIWEB

Updated on June 13, 2022

Comments

  • AKIWEB
    AKIWEB almost 2 years

    I am working with Postgresql database. I need to get date which is two weeks prior to current date using Postgresql database.

    select date(now() - interval '2 week') from test_base
    

    If today's date is 2014-05-08 then above sql should give me 2014-04-24?

    But somehow above query is not working at all?