Skip navigation
Currently Being Moderated

Increase by one calendar day

Jul 19, 2012 9:40 AM

The user enters a Monday date in a date/time object. It is, and needs to be displayed in full (Monday, July 16, 2012) When the user then clicks a check box object, the remaining days of that week are populated into four other date.time objects. I was trying to use the following FormCalc to verify the user selected a "Monday" date and if yes, then add one day for each other field but it does not work.

 

Here's an example form section -

 

// Get the number of days since epoch (Jan 1, 1900).

var dateNum = Date2Num(Day1.formattedValue,"M/D/YYYY")

// Convert the number of days to the full weekday name.

MondayCheck.rawValue = Num2Date(dateNum,"EEEE")

if (MondayCheck.rawValue ne "Monday") then

xfa.host.messageBox("First Requested Day Must Be a Monday.");

$.rawValue = "";

endif

 

DayTwo.Day2.rawValue = Num2Date(Date2num(Day1.rawValue,"YYYY-MM-DD")+1,"EEEE, MMMM D, YYYY");

DayThree.Day3.rawValue = Num2Date(Date2num(Day1.rawValue,"YYYY-MM-DD")+1,"EEEE, MMMM D, YYYY");

DayFour.Day4.rawValue = Num2Date(Date2num(Day1.rawValue,"YYYY-MM-DD")+1,"EEEE, MMMM D, YYYY");

DayFive.Day5.rawValue = Num2Date(Date2num(Day1.rawValue,"YYYY-MM-DD")+1,"EEEE, MMMM D, YYYY");

 
Replies
  • Currently Being Moderated
    Jul 19, 2012 11:53 AM   in reply to DKinsley

    I've done something similar but found it easier to use more variables:

     

    var endDate = Date2Num($,"YYYY-MM-DD")

    var dayOfWeek = Num2Date(endDate, "E")

     

    if (dayOfWeek <> 7) then

              xfa.host.messageBox("Ending date must be a Saturday")

              $ = null

              xfa.host.setFocus("$")

    endif

     

    and then I populate the other fields with this (I don't use date fields for the calculated dates, just text fields):

     

    Pg1.subTableAux.Table1.Row1[6].Date = Num2Date(endDate - 0, "DD")

    Pg1.subTableAux.Table1.Row1[5].Date = Num2Date(endDate - 1, "DD")

    Pg1.subTableAux.Table1.Row1[4].Date = Num2Date(endDate - 2, "DD")

    etc...

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 19, 2012 12:16 PM   in reply to DKinsley

    Yup, it's FormCalc - you can't use Date2Num, etc., in JavaScript.

     

    It will work with date fields but I found the text fields easier to deal with.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 19, 2012 12:44 PM   in reply to DKinsley

    You'd need to wrap the whole thing in another if statement to check the value of the checkbox.

     

    Or you could have the checkbox enable/disable the object that is doing the calculation.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 19, 2012 12:56 PM   in reply to DKinsley

    Yup it works the same but the FormCalc operators seem to work better (eq instead of =, <> instead of !=, etc.).

     

    if (condition) then

         if (condition) then

              do stuff

         endif

    endif

     

    Here's a link to the FormCalc user reference:

    http://help.adobe.com/en_US/livecycle/9.0/FormCalc.pdf

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points