Dying hair

I’ve only dyed my hair once and it came out fine. I think I washed it two days prior to the service and then it was washed during the process. I’m about to dye it again and was wondering if it’s better to wash it days prior, only hours before or if it even matters?