guys please help me with the script. I need a script that checks how many days remaining from actual date to a particular date. This will help me to monitor my work deadline.
trigger= date and time (set to run once a day)
action=script
action=notification on statusbar
particular date must be in dateformat "yyyy-mm-dd hh:mm:ss"
and the remaining days result must be like this "25d"
example:
(2016-09-05 9:00:00) - (2016-09-29 10:00:00) = 25d
subtract date and time
Moderator: Martin
Re: subtract date and time
Hi,
Following script could work:
You could also add one day to the reference date in case it's required:
date = addDays(getDate(2016, 9, 29));
You can also parse a date from a string if desired:
date = getDate("2016-09-29 10:00:00", "yyyy-MM-dd HH:mm:ss");
Regards,
Martin
Following script could work:
Code: Select all
// get the milliseconds since 1970 from the reference date
date = getDate(2016, 9, 29);
// calculate the difference in milliseconds between the reference date and the current date (morning/midnight)
difference = date - getDate(triggertime, 0, 0, 0);
// format the difference as 24d
text = getDurationString(difference);
date = addDays(getDate(2016, 9, 29));
You can also parse a date from a string if desired:
date = getDate("2016-09-29 10:00:00", "yyyy-MM-dd HH:mm:ss");
Regards,
Martin