Date Calculation

  • Profile Image
    p23supply
    Asked on January 11, 2020 at 08:54 PM

    I insert two date pickers: one for the starting date and other one is for ending date.

    I wanted the user to pick only all dates on the Mondays only. So I disabled all other days of the week.

    I am having the trouble to do the calculation. Just say the user picked on Monday 1/13/2020 as a start day and picked a Monday 1/27/2020 as the end date.

    So between 1/13/2020 and 1/27/2020, I want the calculations not calculate all disabled days/dates.

    I used the widget form calculation: end date - start date. However, it calculated all the disabled dates too.

    I just want it to calculate only all the Monday's dates. 

    Please help 

    Thanks

  • Profile Image
    KrisLei
    Answered on January 11, 2020 at 10:47 PM

    Hi,

    I think you have posted a similar query on a different thread.

    To clarify, you would only like to count how many 'Mondays' in between the selected dates, correct?

    It seems that the Date Difference widget was able to exclude the disabled days and calculated only the active days. 

    You would also like to show only the dates selected by the user, correct?

    Let me check further on my end if there's a possible workaround for your form requirements. We will get back to you shortly.




  • Profile Image
    p23supply
    Answered on January 12, 2020 at 04:20 AM

    Yes, that's correct! I just wanted all the Mondays to be calculated and not all the other days.

    And yes, I do try to use the Date Difference widget and it does the calculation wonderfully; however, there are few glitches with the widget.  The calendar doesn't always pop up (see picture below)

    1578820271cap2.PNG 

    And second, I want the widget to display result with start date and end date only.  For example: Start date 1/13/2020 and end date 1/27/2020. I don't want it display Tuesday, Wednesday etc... at the result page.

    Thanks

  • Profile Image
    jherwin
    Answered on January 12, 2020 at 05:12 AM

    Hello @p23supply - Thank you for contacting us. Unfortunately, I was unable to replicate the issue mentioned (please see my following screenshots below), may I know which device and resolution you are using when accessing the form? You can also try to update your browser to the latest version or try using another web browser in filling up your form.

    1578823829asd.png 1578823870asdasd.png

    I have also cleared your form cache. kindly test again. 
    Let us know how it goes on your end.


  • Profile Image
    p23supply
    Answered on January 12, 2020 at 11:05 PM

    Hello jherwin,

    First - it's not always not works. Sometimes it does that. Yes, I tried different browsers too. Also noted that when the phone's on screen keyboard popped up, it sometimes caused the calendar to not fully open. Again it's not always happen like that all the times.

    I will run more tests and will let you know soon.

    And second, I want the widget to display result with start date and end date only.  For example: Start date     1/13/2020 and end date 1/27/2020. I don't want it display Tuesday, Wednesday etc... at the result page. Is this possible?

    Thanks

  • Profile Image
    BJoanna
    Answered on January 13, 2020 at 05:29 AM

    I was unable to replicate the first issue you reported. Please make additional tests and if the issue still persists, please tell us which device and browser are you using. 

    Regarding your second question - I made some tests and the executed days cannot be removed from the submissions page. If you want we can raise a request for a possibility to remove them to our developers. 

    As a workaround, you can use basic Date Picker fields. You can calculate a difference and divide it by 7. 

    1578910962calcualtion.PNG

    How to Perform Form Calculation Using a Widget

    Here is a demo form - https://form.jotform.com/200122403189039

    Feel free to test it and clone it

  • Profile Image
    p23supply
    Answered on January 13, 2020 at 10:41 PM

    Hi BJoanna,

    The example you showed above works great.  So thank you

    I have another calculation that I would like to make: 

    Let's say user the pick Sunday 1/19/2020 (all other days gray out) as starting day and ending day is on Monday 1/27/2020 (all other days gray out as well).

    So how do you calculate this?

    Thanks

  • Profile Image
    p23supply
    Answered on January 15, 2020 at 08:00 PM

    Hello

    Can someone help with the question above?

    Thanks

  • Profile Image
    jherwin
    Answered on January 15, 2020 at 09:20 PM

    Let's say user the pick Sunday 1/19/2020 (all other days gray out) as starting day and ending day is on Monday 1/27/2020 (all other days gray out as well). So how do you calculate this?

    I'm sorry, but your question is unclear to me. What is the calculation you want for this? It will help us provide you with the appropriate workaround/suggestions if you can elaborate further on what you wanted to do for this date picker.

  • Profile Image
    p23supply
    Answered on January 16, 2020 at 01:16 AM

    Hi Jherwin

    https://form.jotform.com/200122403189039

    I would like to do the similar thing like BJoanna had showed above where the user only allow to pick a start date on the Monday and the end date also on Monday only.

    So she did a calculation: 

    (end date - start date)/7 then get the value.

    This time I would like to make the end date on the Tuesday instead of a Monday.

    I want to know how to calculate it.

    I tried to do the calculation like above however, I couldn't the get value correctly. Can you show me the correct equation? I want to get the difference between start date/end date. 

    1579154699mon-picked.PNG1579154757end_tues.PNG

     Thanks

  • Profile Image
    BJoanna
    Answered on January 16, 2020 at 03:02 AM

    What is your expected result when the user the pick Sunday 1/19/2020 (all other days gray out) as starting day and ending day is on Monday 1/27/2020 (all other days gray out as well)?

    Do you want to calculate the number of days between those to dates or the number of Mondays?

    If you want to calculate the number of days, remove /7 from the calculation. 

    1579161474calc.PNG

    And if you want to calculate the number of Mondays add the floor() Math function to the calculation.

    1579161701calc1.PNG 

    Form Calculation - Math Function Reference

  • Profile Image
    p23supply
    Answered on January 16, 2020 at 10:46 AM

    Hi BJoanna

    I want to calculate the number of days between those to dates.

     

    Thank you

  • Profile Image
    KrisLei
    Answered on January 16, 2020 at 12:07 PM

    I want to calculate the number of days between those to dates.

    Thank you for the confirmation.

    If you want to calculate the difference between the Start and End dates, please follow my colleague's (@BJoanna) formula by removing the '/7' on the form calculation widget.

    1579161474calc.PNG

    Let us know if it didn't meet your requirements.



  • Profile Image
    p23supply
    Answered on January 16, 2020 at 02:05 PM

    Hi,

    Not quiet yet. The calculation is not doing what I needed.


    Here's what I want the formula to do:

    And here's example of all dates that I want it to count.

    Start Date

    Sunday (january 19, january 26, February 2)

    End Date 

    Monday (january 20, January 27, February 3)

    I want to get the value between Feb3 and January 19.

    So if you count January 19, January 20, January 26, January 27, Feb 2, and Feb 3, you should get 6 counts

    Please help

    THanks


  • Profile Image
    KrisLei
    Answered on January 16, 2020 at 03:23 PM

    Apologies for the confusion.

    To clarify, you would like to get how many Mondays and Sundays on the selected dates, correct? If so, kindly give me some time to check on the correct formula for the calculation widget. 

    I will get back to you shortly. Thank you.


  • Profile Image
    p23supply
    Answered on January 16, 2020 at 03:47 PM

    Thank you KrisLei

    I'll wait for your answer soon.

  • Profile Image
    p23supply
    Answered on January 16, 2020 at 04:15 PM

    Hello KrisLei

    I believe that I had figured out the calculation

    floor ((end date - first date)/7)*2 + 2

    1579209265formula.PNG

  • Profile Image
    KrisLei
    Answered on January 16, 2020 at 06:03 PM

    Apologies for the late response.

    Glad to hear you were able to come up with the correct formula. 

    If you need further assistance please do let us know by posting a new thread. Thank you.