Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Adding Date/Time Field + X Number of Days - Basic Calculation Question

Avatar

Level 1

I am assuming this is a basic calculation question. New to Adobe LiveCycle Forms.

I have a simple form containing a table. The table appears as such:

Text Formatted as Date/Time FieldsHeader 3
Monday user wil choose the beginning date (Date/Time) this is DateTimeField1
Tuesdaythis should calculate DateTimeField1 + 1
Wednesdaythis should calculate DateTimeField1 + 2
Thursdaythis should calculate DateTimeField1 + 3
Fridaythis should calculate DateTimeField1 + 4
Saturdaythis should calculate DateTimeField1 + 5
Sundaythis should calculate DateTimeField1 + 6

Calculations are performed after the date is chosen for Monday. My mind tells me the simple calculation of DateTimeField1 + 1 is not going to work (and in fact doesn't!) as it needs to change Monday to a number first. I saw on another thread the following:

 

Num2Date(Date2Num(Date(DateTimeField1), "DD.MM.YYYY")+7, "DD.MM.YYYY")

Thought this was going to get me close. No cigars though!

Any quick help is greatly appreciated. And since I am new to this, details about what needs to be changed would be great too!

Thanks

2 Replies

Avatar

Former Community Member

The attached calculates dates for next six days starting Monday. It forces the start day to be a Monday also.

// form1.page1.mon::exit - (FormCalc, client)

var dayNum = Date2Num($.formattedValue,"MM/DD/YYYY")

form1.page1.dayOfWeek.execCalculate()

if (dayOfWeek.rawValue == "Mon") then

          tues.rawValue = Num2Date(dayNum+1,"MM/DD/YYYY")

          wed.rawValue = Num2Date(dayNum+2,"MM/DD/YYYY")

          thurs.rawValue = Num2Date(dayNum+3,"MM/DD/YYYY")

          fri.rawValue = Num2Date(dayNum+4,"MM/DD/YYYY")

          sat.rawValue = Num2Date(dayNum+5,"MM/DD/YYYY")

          sun.rawValue = Num2Date(dayNum+6,"MM/DD/YYYY")

else

          xfa.host.messageBox("The selected date is not a Monday.")

          tues.rawValue = null

          wed.rawValue = null

          thurs.rawValue = null

          fri.rawValue = null

          sat.rawValue = null

          sun.rawValue = null

endif

Steve

Avatar

Level 10

Here an addition for you date field.

This FormCalc script in the exit:Event will check it the selected date is on a monday.

If not it will go the days back until the last monday.

Hope this helps, too.