Update selectDataByDate.R

Edited defensive programming section