PDA

View Full Version : Return future date from text with year first


mokamilk
September 28th, 2011, 06:38 PM
I have a field formatted as text with the year coming first, like so:

20110914

I need it to look like this:

09/14/11

Then I also need to calculate a date 60 days from that field to use as an expiration date.

Any help would be greatly appreciated.

Thanks!

I'm using Mac OSX 10.5.8, Acrobat 9.3.1, and FusionPro 7.1.

Dan Korn
September 29th, 2011, 02:01 PM
I have a field formatted as text with the year coming first, like so:

20110914

I need it to look like this:

09/14/11
var s = Field("MyDateField");
var myDate = new Date(s.substr(0,4), parseInt(s.substr(4,2), 10)-1, s.substr(6,2));
return FormatDate(myDate, "mm/dd/yy"); Then I also need to calculate a date 60 days from that field to use as an expiration date.
var s = Field("MyDateField");
var myDate = new Date(s.substr(0,4), parseInt(s.substr(4,2), 10)-1, s.substr(6,2));
myDate.setDate(myDate.getDate() + 60);
return FormatDate(myDate, "mm/dd/yy");

mokamilk
September 29th, 2011, 02:57 PM
This worked perfectly. Thanks much!