Creating a form... need help with calculating value based on multiple date ranges


i trying create registration form conference.  in form, want offer multiple discounts based on date of registration (basically "early bird" program).  not sure of best way this.  have form total sums areas of registration options.  once total established, total should have discount applied based on date of submission; prior may 31 = 15%;  june 1 - june 30 = 10%, july 1 - july 31 = 5%; after july 31, no discount applied.  can't figure out.  can help? 

put in calculate event of total field (formcalc):

 

var mydisplaypattern = "mmmm d, yyyy" //the display pattern date of submission field var tot = sum(numericfield2, numericfield3) //all fields you're totalling var submissiondate = date2num(dateofsubmission,mydisplaypattern) var submissionyear = right(dateofsubmission, 4) //takes year datofsubmission field, replace year need (ex. "2012") if (submissiondate - date2num(concat("may 31, ",submissionyear),mydisplaypattern)<=0)then //may 31st , prior  tot-(tot*.15) elseif (submissiondate<=date2num(concat("june 30, ",submissionyear), mydisplaypattern)) //june 1 june 30  tot-(tot*.10) elseif (submissiondate<=date2num(concat("july 31, ",submissionyear), mydisplaypattern)) //july 1 july 31  tot-(tot*.05) else  tot //all other dates endif 

 

this assuming submission date field has display pattern "mmmm d, yyyy" (ex. january 1, 2013).

 

it assumes dates of same year submission date.

 

here's sample form whipped up.

 

kyle



More discussions in LiveCycle Designer


adobe

Comments

Popular posts from this blog

Falang and too many redirects - Joomla! Forum - community, help and support

Infinite loop detected in JErrorInfinite loop detected in JError - Joomla! Forum - community, help and support

logged out from joomla! - Joomla! Forum - community, help and support