Edited conditions for adding date
Edited code to determin date