These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Parsing Date Entries in LiveCycle

Marathon1
Registered: May 24 2010
Posts: 2

I've been fighting with this for several hours now and can't figure out how to capture the "day" from a popup date entry.

Here's what I need to do: The user will select a date from the popup date selector, then I need to determine the day of that date to make other decisions on the form. If the day is greater than the 15th of that month, I need to perform a few prorations on selected calculated fields for instance. Is there a way to extract just the day (in numbers, i.e 13, 14, 15, .....) from a date entered from the user by way of popup date selector? If I can get this number stored in a variable, I'm golden! I've successfully programmed what needs to be done -- just can't get that pesky day extracted from the date.

I am a novice, but eager to learn. Thanks in advance for any advice.

John.

Thank You,

John

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The value of the date field is a text representation of the date and it always has the same format:(yyyy-mm-dd). This is very easy to parse using standard string and arrray functions.

For example, this JavaScript code acquires are parses the day value out of a field named "DateTimeField1";

var cDate = xfa.form.form1.pg1.DateTimeField1.rawValue;if(cDate)var nDay = Number(cDate.split("-").pop());

That's all there is to it.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script