little_code
little_code

Reputation: 216

How to define today date in Google app script?

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

Answers (2)

Bhavna Malhi
Bhavna Malhi

Reputation: 3

currentDate= newDAte() From this you can define today date

Upvotes: 0

Serge Hendrickx
Serge Hendrickx

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

Related Questions