Hi all,

I have an example dataset below. I am trying to calculate the duration between the start "date of supply" and "end of date of supply" to tell who has come back for same treatment after 28 days.
As shown, I have duplicated patientid, and the different "date of supply" for the same person. How could I use the last "date of supply" to minus the first "date of supply" to compute the duration days for those data in rows?

Appreciated if you could teach me!

Thanks!
patientid dateofsupply
4656246000 2-Jun-22
4656246000 10-Jun-22
4656246000 3-May-22
5143997512 7-Apr-22
5411626125 20-Jun-22
5624616064 12-Apr-22
5918093125 13-May-22
5918093125 9-Jun-22
11326669343 30-Jun-22
11326669343 7-Jun-22
11814908216 13-Jun-22
12159135216 26-May-22
14296474027 21-Apr-22
14532234008 28-Apr-22
14532234008 24-May-22
17179301512 28-Jun-22
19623147027 30-Jun-22
20031852008 20-Jun-22
20750143343 20-May-22
20750143343 14-Jun-22
23005079008 15-Jun-22
23005079008 19-May-22
26583541008 21-Apr-22
26583541008 28-Apr-22
27419437064 25-May-22
27419437064 5-May-22
27419437064 25-May-22