I am having trouble to compare Postgres SQL Server procedures with Date format(yyyy-mm-dd) and increment the new variable to immediate next date if condition is true.