Welcome aboard. In the future, please start a new thread for a new topic. You can refer to an old thread if you think there is something relevant in it.
Your code is out of context but it includes nothing about the date field. So, you need to add a second condition if you want to include only rows where this field is not null.