I'm trying to write an SQL query that identifies today's date, and then provides the date range for that date's week, so I can return all my database records that fall in that week's date range.
unfortunately, date arithmetic is probably the one area where ANSI SQL is least implemented in the various database systems, so how to do it will likely depend on which one you're using
please re-post your question in the appropriate forum
SELECT * FROM sometable
WHERE datcol BETWEEN (current_date - CAST(dayofweek(current_date)-1 AS interval day))
AND (current_date + CAST(7-dayofweek(current_date) AS interval day))
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.