To find Maximum date

It's hard for us to help without seeing your code. It would be ideal if you could provide a reproducible example (reprex). Please read this guide to see how to create one: