▸_sqlgym

81. Days Between Subscription Dates

EasyDates & Timejulianday

SQLite stores dates as TEXT, so to get a number of days between two dates you convert both to Julian day numbers with julianday(x) and subtract.

Task: for each subscription return id, signup, cancelled, and days_active — the whole number of days between signup and cancelled (cancelled - signup). Both columns are plain 'YYYY-MM-DD' dates, so the difference is already an integer; cast it to an integer with CAST(... AS INTEGER). Order by id.

Output columns, in order: id, signup, cancelled, days_active.

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
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.