Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
2

Date from mm/dd/yyyyy to Date Custom dddd, mmm dd, yyyy

Guest
Sep 10, 2017 Sep 10, 2017

I would like to have DATE in mm/dd/yyyy from FIELD named as "DOS" to be displayed as DATE with custom format dddd, mmm dd, yyyy in another FIELD named as "DOS1".

I am really new in Adobe Acrobat 9 pro.

Thank you for your expertise.

TOPICS
Acrobat SDK and JavaScript
4.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 11, 2017 Sep 11, 2017

Open up the field properties dialog and go to the "Format" tab and select "Date", and in a second step pick the correct date format. If you cannot find the correct format, you can select Custom and then specify the format using the date format symbols (e.g. dddd or mm). You can see what the date would look like in the preview area.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 16, 2017 Sep 16, 2017

Hi Karl,

Thank you for your response.

I do not know how to write a simple JavaScript in Acrobat 9 pro version.

I would like FIELD2 to read the value of Field 1 (Date, MM DD, YYYY)  and display it as custom format dddd, mmm dd, yyyy.

I will enter the value of FIELD 1 manually and then FIELD 2 will display it.

Example: I enter 9/16/2017 in FIELD 1 and then FIELD2 will display "Saturday, Sep 16, 2017".

Thank you again for your expertise

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 18, 2017 Sep 18, 2017

You need to use the custom JavaScript calculation to copy the value of FIELD1 to FIELD2  as well as having the field formats set appropriately.

For FIELD2 you need to use the following custom JavaScript calculation script:

event.value = this.getField("FIELD1").value;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 18, 2017 Sep 18, 2017

Thank you for your advise. It worked and now I have another problem. If I change the Format of Date to Custom "dddd, mmm dd, yyyy" then month and day changes if the month of day numbers are less than 12 and if they are more than 12 then gives me error.

I appreciate the support and advises.

Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 18, 2017 Sep 18, 2017

Example#1: If I enter 8/11/2017 and then it shows "Wednesday, Nov 08, 2017" which it should be "Friday, August 11, 2017"

Example#2: If I enter 12/25/2017 and then it gives me an error saying" Invaid date/time: please ensure that the date/time exists. Field[Field1] should match format dddd, mmm dd, yyyy"

My intention is to keep FIELD1 as mm/dd/yyyy and then FIELD2 as dddd, mmm dd, yyyy

Thank you again

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 18, 2017 Sep 18, 2017

What format are you using for the first field? Is it actually set to mm/dd/yyyy?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 18, 2017 Sep 18, 2017

If one use a more complex calculation to convert a date string into a JavaScript object and trap any errors one should have a more reliable and informative script.

By not clearly specifying the date format and performing the conversion of the date string to a date object JavaScript is assuming a date format of "dd/mm/yyyy" and not the desired "mm/dd/yyyy".

eed to set the format for "FIELD 2" to "None" , the formatting will be performed by the script, and then use the following custom calculation script:

event.value = ""; // clear result field;

var oField1 = this.getField("FIELD 1"); // get FIELD 1 object;

if (oField1 == null) {

// check for access error;

app.alert("Error in accessing FIELD 1", 1, 0, "Field Name Error");

} else {

var oDate = util.scand("mm/dd/yyyy", oField1.value); // convert date value to date object;

if(oDate == null) {

  app.alert("Error converting date string " + oField1.value + " to date object", 1, 0, "Date Conversion Error");

} else {

  event.value = util.printd("dddd mm/dd/yyyy", oDate); // fill in reformatted date value;

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2023 Feb 28, 2023

I have the same problem: I created a custom format for a date field: ddd, mm/dd/yy.

 

Entering the month and day defaults to day and month, providing an error message if the day is greater than 12.

 

If I use mm/dd/yy only, without ddd, the date enters correctly.

 

Any ideas for why Acrobat all of a sudden behaves this way?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2023 Feb 28, 2023

What does you enter for ddd?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 28, 2023 Feb 28, 2023

I don't need to enter anything for ddd. If I enter, say, "2/11/23," it'll default to "Thu, 11/02/23." Indeed, the 11th of November in 2023 is a Thursday.

 

The custom preview box uses today's date and is correct: as I type ddd, "Tue" appears; as I type mm, "02" appears; as I type dd, "28" appears; as I type yy, "23" appears.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 01, 2023 Mar 01, 2023

This is a bug in Acrobat.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 01, 2023 Mar 01, 2023

I'm not sure I would call it a bug. You're entering a value that doesn't match the provided format, so Acrobat has two options:

- Reject it entirely (and then many people will complain about it not accepting their input), or

- Assume it follows some default format, and try to handle it that way. It just so happens that format is mm/dd (following the American style), which is why you're getting wrong results if your format follows another convention.

The solution is to enter the full date, in the correct format, or use the calendar widget to select the date.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 01, 2023 Mar 01, 2023

When I use the calendar on the date field I get this:

Bild4.jpgexpand image

 

Bild5.jpgexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 01, 2023 Mar 01, 2023

Thanks for the explanation, Try67. Even if I type "Wed, 03/01/23," the date defaults to "Tue, 01/03/23."

 

I found that if I type "Wednesday, March 1, 2023," the date defaults to "Wed, 03/01/23" as intended, which defeats my purpose. And if I type "Friday, March 24, 2023," it defaults to "Fri, 03/24/23," which is also as intended.

 

Incidentally, if the day and date don't match, say "Friday, March 1, 2023," it corrects the day to match the date: "Wed, 03/01/23."

 

Life for Berndt, the date-picker doesn't work if the intended day (dd) is greater than 12. I think it's buggy, if not an actual bug.

 

I changed the field to default to one of Acrobat's formats to get around the issue,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 02, 2023 Mar 02, 2023

Not an helpfull answer but think about it:

😉

 

ISO-8601 Date format.pngexpand image


Acrobate du PDF, InDesigner et Photoshopographe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 02, 2023 Mar 02, 2023

Understood! If only I could implement organization-wide...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2023 Mar 09, 2023
LATEST

++Adding to the topic,

 

This is not a bug as pointed out by @try67 and also @JR Boulay is absolutely correct about employing the correct concept of ISO date standards.

 

The issue that you've observed happens with both the month and the day values depending on how they are interpolated in the date notation.


What is truly missing in this conversation is a small observation but with a more detailed, long and boring (yet important) clarification.

 

The date notation standards have been unique throughout history since the Old World versus the New World colonization. And the way that the date/time should be used with written formal papers, or expressed grammatically when publishing citations, to include military or International date/time standards accross the globe, have a reason and its purpose.

 

If you dig some more about why the US is the only country in the world that employs a date notation in which the month comes before the day , and more specifically with short date expressions (such as mm/dd/yy) that are accepted only by North Americans, you will see clearly why the Acrobat JavaScript core interpreter throw an alert to the user simply to point out an error with the date notation that is employed with that document.

 

For example, as opposite to the US , Europeans (and mostly every other country in the world, with the exception of some Asian nations that use ISO standard yyyy-mm-dd), are OK with dates that are expressed with the day before the month as the official date notation standard.

 

And if we take the same premise and apply it to how to use  short expression dates (such as "03/18/19") in a paper or a formal document, it would make it really hard for different users accross the world to understand what is the day, what is the month, and even the century that the publication (or PDF document in this case) is citing.

 

In other words, even though in the US it may be accepted (or considered OK) to cite a date informally, like for example "Fri, March 03, 2023" or "Friday, Mar 3, 2023", this doesn't necessarily means that it is also correct to turn an US short date into a long date notation format (like the one you are trying to force with your PDF): "Fri, 03/18/23"... specifically where the day of the week comes before the month, but the month is notated before the calendar day and expect every person in the world could (or should, or would) understand what exaclty is the date that you are trying to express.

 

In which case, if you use that format the short date notation is no longer short, but a long date notation format.


So, if you are going to do that, then (from the propper grammar standards in writing and formal date expressions standards) you may not abbreviate the day and the month; it has to be explicitely worded out like "Friday, March 04, 2023".

 

You will notice that if you express the date notation like "ddd, mmm/dd/yy" in Acrobat it will work. Nevertheless,  it is grammatically incorrect and much less the proper date notation standard.

 

If we break down further your desired current date notation, Note that you are citing an abbreviated day of the week "Fri" and immediately jump to the month number "mm/" notation, then jump back to the calendar day notation "dd/" and lastly the abbreviated year notation "yy" (dashes, periods, or slashes are irrelevant in this context).

 

With all that said, instead of using "ddd, mm/dd/yy" (where the month comes before the calendar day), you must interpolate the calendar day notation before the month number notation like shown in this long date notation: "ddd, dd/mm/yy" in order to make it acceptable as an informal date expression.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines