Days of service at a cut-off date
Your task
Given staff with columns name, team, salary, hired and manager, and an ISO cut-off date, return how many whole days each person had been employed on that date, as days. People hired after the cut-off are excluded. Return name and days, sorted by name ascending.
Examples
days_served(staff: dataframe, as_of: str) -> dataframeExample 1
Input
days_served(staff, "2024-01-01")staff
More rows not shown
| name | team | salary | hired | manager |
|---|---|---|---|---|
| Ada | eng | 120 | 2021-03-01 | Grace |
| Grace | eng | 150 | 2019-06-15 | NULL |
| Linus | eng | 95 | 2022-01-10 | Grace |
| Mel | sales | 80 | 2020-11-05 | Kay |
| Kay | sales | 110 | 2018-02-20 | NULL |
| Ivan | sales | 80 | 2023-07-01 | Kay |
| Jean | design | 105 | 2021-09-30 | NULL |
| Nia | design | 140 | 2022-05-04 | Jean |
Output
More rows not shown
| name | days |
|---|---|
| Ada | 1036 |
| Grace | 1661 |
| Ivan | 184 |
| Jean | 823 |
| Kay | 2141 |
| Linus | 721 |
| Mel | 1152 |
| Nia | 607 |