Skip to content
Advertisement

Get the logs of the current week in postgresql

I need to get the logs of the current week in postgresql, I have tried to use the native mysql functions yearweek for that, but here in postgresql it is different

This is my table

Basically I need to get the records of the current week based on the records in the column fecha_registro

Advertisement

Answer

Use date_trunc():

Note: Postgres understand weeks as defined by ISO, meaning that a week starts on Monday.

If your table may contain dates in the future, you might want an upper bound too:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement