Mongoexport with --query option to export some columned for last calendar day

Please apply the same solution. Make sure $last_date is interpreted as a shell variable and that $gte and $date are not. This being written. I notice that you are using Windows. This means that you might want to use %last_date or %last_date% as it is how, I think, Windows identifies variable.