Exercise

# Calculating days elapsed between incidents

Something you might have noticed in the prior two exercises is that we don't always have incidents on every day of the week, so calling `LAG()`

and `LEAD()`

the "prior day" is a little misleading; it's really the "prior period." Someone in management noticed this as well and, at the end of July, wanted to know the number of days between incidents. To do this, we will calculate two values: the number of days since the prior incident and the number of days until the next incident.

Recall that `DATEDIFF()`

gives the difference between two dates. We can combine this with `LAG()`

and `LEAD()`

to get our results.

Instructions

**100 XP**

- Calculate the days since the last incident using a combination of
`DATEDIFF()`

and`LAG()`

or`LEAD()`

. - Calculate the days until the next incident using a combination of
`DATEDIFF()`

and`LAG()`

or`LEAD()`

. **NOTE: you will not need to use the**`NumberOfIncidents`

column in this exercise.