ken bohnenkamp
18th August 2003, 14:48
I have a form field that a user will enter called periods. These periods are actually months. If todays date is 1/1/2003 and I want to add the user entered 26 periods to this date so that the date becomes 3/1/2005 how would I do something like this. Any help would be appreciated.

lbencic
18th August 2003, 18:19
There's no great way to do this, but using the date functions, you can accomplish it:





domain tcdate in.date, out.date
long in.year, in.month, in.day, add.periods, i
.....
|* Assume in.date = 1/1/2003
|* Assume that add.periods = 26
num.to.date(in.date, in.year, in.month, in.day)
|* fills in.year = 2003, in.month = 1, in.day = 1
for i = 1 to add.periods
in.month = in.month + 1
if in.month = 13 then
in.month = 1
in.year = in.year + 1
endif
endfor
out.date = date.to.num(in.year, in.month, in.day)
|* out.date should now equal 3/1/2005