Thanks, there are no errors now, but I'm getting a blank result.  So I 
tried to troubleshoot by having it spit out just the variable "year" and 
that was blank too.

exports.run = function(duedate) {
//Make each date object.
var date1 = new Date();
var mydate = new Date(duedate);
var year = mydate.getUTCFullYear();
var month = mydate.getUTCMonth();
var day = mydate.getUTCDate();
var date2 = new Date(year, month, day);

//Find difference in milliseconds.
var elapsed = date2.getTime()-date1.getTime();

//Number of milliseconds in a day.
var dayMS = 86400000; 

//Convert milliseconds to year months and days
var days_diff = Math.floor(elapsed/dayMS);
var result = days_diff;

return year;
};

Any suggestions?  I would have expected a return of "2020" as the tiddler I 
tested it in has field "duedate" of "20200214"

Also I googled again and found this:   
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_getutcfullyear2

and I can replace this   
var d = new Date("July 21, 1983 01:15:00");

with this   
var d = new Date("2020-02-14");

and that works, but when I replace it with this  (which is the format of my 
duedate field)
var d = new Date("20200214");

it says NaN

is that maybe the source of my problems?

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/df9f788e-0e88-420b-8931-408351b14e0b%40googlegroups.com.

Reply via email to