improved NULL handling in expiration time SQL