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

Value based on date

New Here ,
Feb 13, 2016 Feb 13, 2016

I want a value returned in Text1 field based on a date in Date1 field. For instance if the date in the Date1 text field is todays date or before than the value in the Text1 field should be "Expired" if the value in the Date1 text field is tomorrow or any time in the future than the value in the Text1 field should be "Expires"

TOPICS
Acrobat SDK and JavaScript , Windows
428
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 13, 2016 Feb 13, 2016

What's the format of the value in Date1?

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
New Here ,
Feb 13, 2016 Feb 13, 2016

dd/mm/yy

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
New Here ,
Feb 13, 2016 Feb 13, 2016

However the date could be 3/1/16

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
New Here ,
Feb 13, 2016 Feb 13, 2016

not sure if that is still dd/mm/yy or d/m/yy

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 13, 2016 Feb 13, 2016
LATEST

You can use this code as the custom calculation code for Text1:

event.value = "";

var s = this.getField("Date1").valueAsString;

if (s!="") {

    var d = util.scand("dd/mm/yy", s);

    d.setHours(0);

    d.setMinutes(0);

    d.setSeconds(0);

    d.setMilliseconds(0);

    var now = new Date();

    now.setHours(0);

    now.setMinutes(0);

    now.setSeconds(0);

    now.setMilliseconds(0);

    if (d) {

        if (d.getTime()<=now.getTime()) event.value = "Expired";

        else event.value = "Expires";

    }

}

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