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

  • Mareid
    Asked on September 17, 2014 at 5: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

  • Mike_T Jotform Support
    Replied on September 17, 2014 at 6:34 PM

    Thank you for contacting us. 

    You might consider the following workaround.

    Add the standard $30 price to your calculation field.

    Is there a way to calculate the day of the year considering leap years Image 1 Screenshot 40

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

    Is there a way to calculate the day of the year considering leap years Image 2 Screenshot 51

    Is there a way to calculate the day of the year considering leap years Image 3 Screenshot 62

    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.

  • Mareid
    Replied 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
    ...