Is there a way to calculate the day of the year considering leap years

  • Profile Image
    Mareid
    Asked on September 17, 2014 at 05:04 PM

    Is there a way to capture the day-of-the-year (e.g. September 1 i s day 244 in non leap years)

    I want to set up my for so that if the this year is not a leap year (i.e. it is not divisible by 4) and the day of the year is between 152 and 365, the cost to register is $15, otherwise it's $30.

     

    I don't know how to calculate the day of the year within the form. And I need to be able to determine whether the year itself is evenly divisible by 4 (in which case it is day 153 and 366)

     

    Thanks

  • Profile Image
    Mike_T
    Answered on September 17, 2014 at 06:34 PM

    Thank you for contacting us. 

    You might consider the following workaround.

    Add the standard $30 price to your calculation field.

    And set up an 'Update a form field value' condition.

    It means that you will need to update that condition once a year to change the years.

    It is probably that there is a way to calculate the leap years and the day of the year based on a Form Calculation widget, since it can provide the dateString value (calculated based on a 1 January, 1970 UTC start date), but I have not found a solution yet.

    Please feel free to contact us if you need any further assistance.

  • Profile Image
    Mareid
    Answered on September 17, 2014 at 11:01 PM
    Mike,
    I figured out a way to do it without having to modify the form every
    year. I checked which month we were in and the appropriate month
    triggers a value in a field. You can see how I did it on WGRI
    Membership Application Form.
    Pam
    ...