Avatar

Level 10

The attached 'GetDaysStartingSunday.pdf' produces the following results:

p1.png

You pick Sunday's date and the dates for rest of the week are calculated. You can see the FormCalc functions handle dates across months. The form has no logic to validate that the date picked for Sunday is actually a Sunday. This is possible, however. The exit event on the field 'sun', below, converts the selected date to a number (Date2Num) representing the number of days since 01/01/1900. Each subsequent calculation adds 1 to that number and converts the number to a date (Num2Date).

// form1.page1.subform1.table.row.sun::exit - (FormCalc, client)

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

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

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

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

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

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

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

I have attached another time sheet example that allows users to enter time in/out and calculates the daily hours and a total. The time must be entered in 24-hour format (where 8:00 AM is 0800 and 5:00 PM is 1700, for example). It might give you some ideas.

Steve