Another solution that could be used in other PDF by adding the following the following scripts to the document level functions for a PDF: // document level code; Date.prototype.isLeapYear = function() { // determine if a year is a leap year or not; // this crates a new property for the Date object; // input date object; // return 1 if a leap year 0 if not a leap year; var year = this.getFullYear(); if((year & 3) != 0) return false; return ((year % 100) != 0 || (year % 400) == 0); } // Get Day of Year Date.prototype.getDOY = function() { // determine the day of year for a given date; // This code creates a new propety for the dote object; // input date object; // returns the day of the year adjusted for leap years; var dayCount = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; var mn = this.getMonth(); var dn = this.getDate(); var dayOfYear = dayCount[mn] + dn; if(mn > 1 && this.isLeapYear()) dayOfYear++; return dayOfYear; } // end document level code; And then the field calculation script would be: var cNowDate = this.getField("Date").valueAsString; var cNowFormat = "d-mmm-yyyy"; event.value = ""; if(cNowDate != "") { cNoow = util.scand(cNowFormat, cNowDate); event.value = oNow.getDOY(); } One only needs to change the name of the input date field and the format for that field. The code for the leap year method could be used in other date calculations when one needs to determine if a year is a leap year. Note that both document level code listings create two new properties for the Date object.
... View more