I would like to write a definition query expression to get features where a date field is in the current week (starting Sunday ending Saturday)
I have difficulties to imagine how using CURRENT_DATE would help me in that case.
I want the definition expression to returns the same features from Sunday to Saturday.
My feature class is stored in PostGreSQL (ArcGIS Enterprise)
Solved! Go to Solution.
The solution I have found with Postgres
EXTRACT(WEEK FROM mydatefield) = EXTRACT(WEEK FROM CURRENT_DATE) + 1 AND EXTRACT(YEAR FROM mydatefield) = EXTRACT(YEAR FROM CURRENT_DATE)
Some good discussion here: how to get data of current week only in SQL server? - Stack Overflow . The discussion is focused on SQL Server but Postgres also has a DatePart function (PostgreSQL: Documentation: 12: 9.9. Date/Time Functions and Operators ).
The solution I have found with Postgres
EXTRACT(WEEK FROM mydatefield) = EXTRACT(WEEK FROM CURRENT_DATE) + 1 AND EXTRACT(YEAR FROM mydatefield) = EXTRACT(YEAR FROM CURRENT_DATE)