Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 337
AKIWEB Avatar asked Aug 27 '26 02:08

AKIWEB


1 Answers

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.

like image 124
Patrick Avatar answered Aug 29 '26 15:08

Patrick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!