Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - convert date from MM/DD/YYYY to MM/YYYY
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

convert date from MM/DD/YYYY to MM/YYYY

 Post Reply Post Reply
Author
morrison View Drop Down
New Member
New Member
Avatar

Joined: 26 Jan 2015
Points: 32
Post Options Post Options   Quote morrison Quote  Post ReplyReply Direct Link To This Post Topic: convert date from MM/DD/YYYY to MM/YYYY
    Posted: 23 Aug 2016 at 12:06am
A form's completion date is in MM/DD/YYYY format.  It must be in that format to satisfy other requirements. 
However, in order to perform calculations elsewhere on the document, the form's completion date must be formatted as MM/YYYY.

I was going to take the MM/DD/YYYY entered by the user and pass it to a hidden field and use the value in that hidden field against which to do the other calculations.  The problem is that I keep getting "/undefined" as the value in the hidden field.  Could somebody please indicate what changes are necessary in the script below in order to pass just the MM and YYYY from the completion date to the hidden field?

The following is in the hidden field as a custom calculation script:

var dotAppDate = this.getField("dot_emp_app_date").value  // get completion date value
var array = new Array();  // define array
array = dotAppDate.split("/");  // split string and store it into array

if(dotAppDate.value!="") //if the completion date is not blank
{
var newAppDate = (array[0] + "/" + array[2]);
// from array concatenate into new date string format: "MM/YYYY"

event.value = newAppDate;  // set the new date string as this field's value
}

else if(dotAppDate.value=="")  // if the completion date is blank
{
 event.value = ""; // this field is blank
}


Thank you,
~morrison

Back to Top
Sponsored Links


Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 615
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 24 Aug 2016 at 1:17pm
In your if-statements, change dotAppDate.value to just dotAppDate .
You've already defined that variable as the value of the field. There's no need to use ".value" again...
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
morrison View Drop Down
New Member
New Member
Avatar

Joined: 26 Jan 2015
Points: 32
Post Options Post Options   Quote morrison Quote  Post ReplyReply Direct Link To This Post Posted: 24 Aug 2016 at 2:10pm
  -- bangs head on desk --
(Those times you can't even *see* the code anymore... )

Thank you for pointing out the extra .value in the if statements.

It works perfectly now.  :-)  Thank you.  :-D
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.031 seconds.