how to set conditions based on length of time