How to add a conditional statement "TO date not earlier than FROM date"?