Jasmine22 Jasmine22 - 2 months ago 7
PHP Question

PostgreSQL run query for today's date

I found a lot of questions similar to mine, but none seemed to work
I have this query

$query= "SELECT * from jazz WHERE parsing_date = (todays date) ";


I want "
parsing_date
" to equal to today's date I work on PostgreSQL.
For it to get from my database all records that have today's date. Also
parsing_date
has date format.

Answer

In PostgreSQL there are next date-constants: CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP or universal function now().

Try next query in your case:

$query = "SELECT * from jazz WHERE parsing_date=CURRENT_DATE";