Is there a way to count how many days left in the month

  • Profile Image
    simhc
    Asked on April 17, 2016 at 11:37 PM

    I cant seem to find a way to create a formula that will calculate how many days left in the month.  I want to use that number to calculate a prorated amount.  thanks for your help.

  • Profile Image
    jonathan
    Answered on April 18, 2016 at 01:22 AM

    I cannot find a function that gives the number of Days of a Month -- so you will need to either assume a fixed 30/31 days and calculate

    OR 

    Get first the Month's number of days (example: April is 30days) and just substract the current date (number of days up to date) -- this will give the remaining days of the month

    I will try create a demo form you can check. I'll get back to you shortly.

     

  • Profile Image
    jonathan
    Answered on April 18, 2016 at 02:29 AM

    Please test my form https://form.jotform.com/61081009373954

    It work like this

     

    Hope this help. Let us know how it goes.

  • Profile Image
    grade4pagasa
    Answered on April 18, 2016 at 02:26 PM

    Hi simhc.

    Here's a draft form I created based on the specifications you gave. It's a bit more involved to create this since all the calculations will be based on whatever date that will be entered - meaning there's a need to create intermediate variables (fields) since there's no built-in function to handle your specs.

    You just have to select the date and it will automatically compute for the End of Month (EoM) and the days left before the EoM.

    I got stuck in the conditions for calculating the days when it's a leap year (figuring out if the End of Month for Feb is 28 or 29). Haven't tested it fully yet but I think it works :) 

    Hope this helps or maybe spark an inspiration for you to create your own. 

    And feel free to modify it to suit your needs. Or if anyone has a better method, please share your solution.

    - Randy, fellow JotForm user. 

    * Note: I'm not a coder or a designer.

  • Profile Image
    simhc
    Answered on April 18, 2016 at 02:26 PM

    Thanks for the quick responses and example form.  Ideally I would like to have the end date calculated automatically.  I played around with some temp forms and tried to set some conditions to do this.  I tried to create a condition for each month...say if today is before May 1 or after Mar 30 then set the {end date} to 30 april and set the {number of days in the month} to 30.  I could then use that info to subtract how many days are left in the month and do a calculation to find the percentage of the month remaining to determine a prorated charge.  I cant seem to get that initial logic (calculating the end date) to work. any ideas?  thx.

  • Profile Image
    simhc
    Answered on April 18, 2016 at 02:29 PM

    Thanks so much randy.  That is exactly what I wanted.  I will play with it and see if I can get that to do what I need.   Disregard my last message that was not meant for you.  

  • Profile Image
    Mike
    Answered on April 18, 2016 at 04:28 PM

    What a beautiful example! We appreciate your input, Randy.

  • Profile Image
    simhc
    Answered on April 18, 2016 at 07:15 PM

    Randy, the form you created worked perfectly.  It provides all the information I need to do the prorated calculations.  Thank you so much for taking your time to help me out.  I had spent hours trying to get that to work. You even accounted for leap year…I’m impressed!  Thanks again to everyone that helped answer my question.  

  • Profile Image
    grade4pagasa
    Answered on April 18, 2016 at 07:53 PM

    Thanks for the kind words, simhc. 

    Trying to help fellow users is the least I could do to repay JotForm for their awesome and free service.

    Glad to be of help.

    - Randy