Skip to content
Advertisement

Why current_date() incurr errors in postgres sql

I have sql like following.

select *
from table
where
      c.date >= date_sub(current_date(), interval 4 day)

But it returned following errors

Syntax error at or near Line 19, Position 35

This error was caused by current_date(). How can I avoid this and how can I get current date ?

If someone has opinion,please let me know

Thanks

Advertisement

Answer

date_sub() function is only available in Mysql , and current_date in postgresql is not a function.

here is the correct postgresql syntax:

select *
from table c
where c.date >= current_date - interval '4 day';
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement