Expand my Community achievements bar.

SOLVED

Check box as Date comparsion

Avatar

Level 2

Hello,

i have a date field and i would like to have a check box checked if the date inserted in the date field is <3 moths from today

how to do this

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Have a look at this form, https://sites.google.com/site/livecycledesignercookbooks/home/Bassel.pdf?attredirects=0&d=1

Is there any specific errors you were getting?

I was not sure how you wanted to handle the days of the months, so the method above ignores the days and just compares the months.  But you could easily extend this approach if needed.

Regards

Bruce

View solution in original post

4 Replies

Avatar

Level 10

Hi,

You could use something like the following FormCalc in the calculate event of the checkbox;

 

if (HasValue(DateField1)) then

 

    var monthsNow = Format("MM", Num2Date(Date(), "YYYY-MM-DD")) + Format("YYYY", Num2Date(Date(), "YYYY-MM-DD")) * 12

 

    var monthsInput = Format("MM", DateField1) + Format("YYYY", DateField1) * 12

 

    if (monthsNow - monthsInput > 3) then

 

    1

 

    else

 

    0

 

    endif

 

endif

 

This just calculates the number of months since Jan 1900 for the current date and for the value entered into the date field DateField1.

Regards

Bruce

Avatar

Level 2

Hello Bruce

Thanks for your help

unfortunately it didn't work

can you send me the form you created using this formula

bmalo@photomedex.com

Again, appreciate your help

Thanks

Avatar

Correct answer by
Level 10

Hi,

Have a look at this form, https://sites.google.com/site/livecycledesignercookbooks/home/Bassel.pdf?attredirects=0&d=1

Is there any specific errors you were getting?

I was not sure how you wanted to handle the days of the months, so the method above ignores the days and just compares the months.  But you could easily extend this approach if needed.

Regards

Bruce