86. First and Last Day of Each Month
MediumDates & Timedate modifiersstart of month
SQLite's date modifiers make month boundaries easy: date(x, 'start of month') jumps to the 1st, and date(x, 'start of month', '+1 month', '-1 day') lands on the last day of that month (handling 28/29/30/31 automatically).
Task: for each row return id, any_date, month_start, and month_end — the first and last calendar day of the month that any_date falls in. Order by any_date.
Output columns, in order: id, any_date, month_start, month_end.
Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…
This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases — 5test cases in all. A sloppy query that only fits the example won't pass.
SQL· SQLite · runs in your browser
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.