I would like to thank those who replied to my previous posting regarding calculating dates. Based on those replies perhaps I did not explain well what the problem is that I have.
As in my previous postingI created an expense report form which povides space for up to 14 days, with 2 calendars to indicate the period covered`(e.g. Starting Date % Ending Date).
What I would like to do, is that based upon the Start & End Date, the individual dates are entered at the top of each column.
With FormCalc I have entered the following code:
-------------------
"Date1:calculate"
-------------------
// Check that Starting Date and Ending Date are not empty
if (HasValue(StartDate) & HasValue(EndDate)) then
// Enter the Starting Date as the heading of the 1st column based on the StartDate & EndDate
Date1.formattedValue = Num2Date( Date2Num(StartDate.formattedValue, "MMM. D, YY"), "MM/DD/YY")
else
// Clear Field
Date1.formattedValue = ""
endif
-------------------
"Date:2calculate"
-------------------
// Check that Starting Date and Ending Date are not empty
if (HasValue(StartDate) & HasValue(EndDate)) then
// When the Ending Date is > then the Starting Date complete date in 2nd column by adding + 1 to Starting Date
Date2.formattedValue = Num2Date( Date2Num(StartDate.formattedValue, "MMM. DD, YY") + 1, "MM/DD/YY")
else
// Clear Field
Date2.formattedValue = ""
-------------------
"Date3:calculate"
-------------------
// Check that Starting Date and Ending Date are not empty
if (HasValue(StartDate) & HasValue(EndDate)) then
// When the Ending Date is > then the Starting Date complete date in 3rd column by adding + 2 to Starting Date
Date3.formattedValue = Num2Date( Date2Num(StartDate.formattedValue, "MMM. DD, YY") + 2, "MM/DD/YY")
else
// Clear Field
Date3.formattedValue = ""
etc....... until "Date14"
The problem I have is that all the columns are being completed regardless what the End Date is.
Any help, on how I would have to modify my code so that only dates from starting date to ending date are completed and the other column remain blank. would be appricated.
Martin
Or is it that the expense report doesn't always require 14 days. For instance you only want to submit 2 days of expenses and you only want those two days on the form?