Reputation: 216
I am defining date = new Date();
.
.
.
old_date < today_date
in my app script for a particular task.
Task is to send Email when old_date < today_date. But it is working as the process old_date <= today_date. How can I write the exact query? Any help will be really appreciated.
*dots(.) are the other code statements.
Upvotes: 0
Views: 11685
Reputation: 1416
Date currentDate = new Date() gives you the time right now.
old-date < currentDate is true for everything that happened before the new Date() call. Thus something that happened an hour ago will also get called.
You want currentDate to be today at 00:00 am. This could be done this way:
var d = new Date();
d.setHours(0,0,0,0);
Keep timezones in mind if you run into some issues.
Upvotes: 2