Moving and dividing hostas and lilies

Hi, I have hostas and lilies that have outgrown their space. I would like to dig them up and move them or divide them. I am wondering when is a good time to do this? Thanks…