2 Replies Latest reply on Apr 28, 2017 6:24 PM by ianp333321

    Add Two Days to Date Field

    aaronm91043268 Level 1

      I have two date fields binded through global data. When a date is selected it auto fills to another date field. I would like that second date field to add two days to that date automatically. It would be a read only for the second date field. Is there a way to do this without having to change it to a text field, however, any way to achieve this would be great...I am pretty stumped..

        • 1. Re: Add Two Days to Date Field
          Magus069 Level 4

          Hi there,

           

          to do this you I suggest you to use the language FormCalc, it can use functions which are easy to use to manipulate dates

          Date2Num(date, format) (returns the number of days since 1st January 1900)

          and

          Num2Date(number, format) (returns a date format)

           

          The date field which you want it to be readOnly will need to have the following FormCalc script within the calculate event

          if (DateTimeField1.rawValue <> null) then

                Num2Date(Date2Num(DateTimeField1.rawValue, "YYYY-MM-DD") + 2, "YYYY-MM-DD")

          else

                null

          endif

          Hope this help!

          1 person found this helpful
          • 2. Re: Add Two Days to Date Field
            ianp333321

            Hi Magus069,

             

            I know this is an old post but I've literally gone stir fry trying to figure this out and have spent countless hrs digging the net for this answer and it worked perfectly for me.

             

            Thank you kindly

            Ian