Fixed the apply time problems and added a aggregate functions for date.