Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Calculate end date from start date and radio button values

Avatar

Avatar
Level 1
mommamoo1962
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
mommamoo1962
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
mommamoo1962
Level 1

08-11-2016

Using FormCalc, I wish to calculate from a user entered start date, adding 90, 180 or 365 days to get to get an end date. I am using radio buttons for the 90, 180 and 365 days.  So far I have this:

(radioButton.rawValue==1)//radio button bound to 1 is on/yes then;//

and I have this:

current=Date2Num(Start_Date.rawValue,"MM/DD/YYYY")

future=current+90

newDate=Num2Date(future,"MM/DD/YYYY")

= newDate

but I don't know how to put them together or incorporate the 180 and 365 days.  I know the second part works because I currently use it, but that is as far as I have gotten.

Any help/suggestions will be greatly appreciated!!!

Thanks,

Lou Johnson

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Boost 1
Level 2
KayDobe
Level 2

Likes

2 likes

Total Posts

10 posts

Correct Reply

5 solutions
Top badges earned
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Boost 1
Level 2
KayDobe
Level 2

Likes

2 likes

Total Posts

10 posts

Correct Reply

5 solutions
Top badges earned
Boost 1
Affirm 3
Affirm 1
View profile
KayDobe
Level 2

24-02-2017

Take a look at this answer I gave another person about adding days to dates: Re: Adding Days to a Date​.

So, depending on whatever value the user picks from the radio button (90, 180, 365), add that number to a periodSelect variable, then run a  Num2Date call to set the value of the newDate field.  The example below presumes you have a radio button called radioButton1 with default button values of '0' for 90 days, '1' for 180 days, and '2' for 365 days.

Example:

var periodSelect

var newDate_Num

if (radioButton1.rawValue == "1") then

    periodSelect = 180

elseif (radioButton1.rawValue == "2") then

    periodSelect = 365

else

    periodSelect = 90

endif

newDate_Num = Date2Num(Start_Date.formattedValue, "YY/DD/YYYY") + periodSelect

newDate.rawValue = Num2Date(newDate_Num, "YY/DD/YYYY")

Caveat to using .rawValue versus .formattedValue when it comes to date fields (something I had to figure out/learn on my own the hard way): .rawValue will be zero if the user clicks in the date field and picks via the drop-down calendar rather than types it in.  My best guess is that happens because the calendar drop-down box mouseclick isn't a date, but a window coordinate that the subroutine has to convert into a date for the .formattedValue.

Hope this helps.

- Kaye