Practice / strings dates nulls

Membership Length

medium

PulsePoint gym wants to know how long each membership lasted.

members

Both dates are stored as yyyy-MM-dd strings.

Your task: return member and days — the number of days between started and ended.

Assign your answer DataFrame to result. Row order doesn't matter.

membersinput DataFrame

Schema
columntype
memberstring
startedstring
endedstring
Sample rows
memberstartedended
Ada2026-01-012026-01-11
Ben2026-03-012026-03-08
Expected output shape
memberdays· 2 rows
Hint

Parse both strings with F.to_date(col, "yyyy-MM-dd"), then F.datediff(end, start) — end date first — gives whole days between them.

Lesson refresher

This problem builds on Strings, Dates & Nulls (~8 min). Pop it open in a new tab if you want a quick recap.

Loading editor…
Hit Run to execute your code and see the output here.