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

ANDY_ALDRICH

Total Posts

1

Likes

0

0

ANDY_ALDRICH

Total Posts

1

Likes

0

0
ANDY_ALDRICH

09-11-2011

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

View Entire Topic

Steve_L_Walker

Total Posts

1.4K

Likes

197

212

Steve_L_Walker

Total Posts

1.4K

Likes

197

212
Steve_L_Walker

09-11-2011

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