Answered
Hello, I have a date time stamp coming back from a sql db into one of my forms. I want to display only the date portion of this sting.
here is what I get:
m/d/yyyy 121212:2345
OR
mm/dd/yyyy 121212:2345
I only want the date, not the time portion coming from the DB. Is there a way to grab the string and end at the space between the date and the time?
I know I can just set the format properties inside of adobe, but that generates alot of errors for me during import process (long story)
anyways, here is what I last tried:
var dob = event.value;
if (dob.length > 10)
{
event.value = dob.indexOf (0," ");
}
Thanks in advance, I know this is probably baby stuff to you guys but I'm really struggling.
event.value = event.value.split(" ").shift();
If the string doesn't contain a space you'll get the whole string back and if the string is empty there won't be any errors. The only problem happens when the string is null, so you could protect the code like this
if(event.value != null)
event.value = event.value.split(" ").shift();
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