Comparing dates

  • systemserenity
    Asked on February 19, 2015 at 9:42 AM

    I need to be able to take in month and day of someone's birthday in fields and then determine with a calculation if it has occured yet this year.

    If it has, I use this year (2015) in future calculations.

    If it hasn't, I use last year (2014) in calculations....

    In other words, I need the year that there last birthday happened.

    I have their birth month in a field.

    I have their birth day in a field.

    AND I have today's date.

     

  • David JotForm Support
    Replied on February 19, 2015 at 12:31 PM

    Hi,

    Unfortunately, no, we do not have such a feature. Our conditions system can only compare a date field with an exact date value, and not with another date field.  It is possible to compare date fields to a specific date.  For example , the conditions wizard will use an EXACT date value  and then setup a BEFORE of AFTER condition - THEN SHOW/HIDE  {a field}

    Comparing dates Image 1 Screenshot 20

    However it is not currently possible to have this date change to the current date on a daily basis.

    I hope this made things a bit more clear.  If you have any further questions, let us know and we will be happy to help.

  • systemserenity
    Replied on February 19, 2015 at 12:57 PM

    This may be what I need if I can create a date from individual month, day and year numbers

    Is that possible... to build a date?

  • David JotForm Support
    Replied on February 19, 2015 at 2:21 PM

    This may be possible with updating three different fields.  You would set the condition to update a day field, month field and year field.  You can update the fields to whatever you would like:

    Comparing dates Image 1 Screenshot 20

    Then you can update other fields with whatever you would like, based on the date selected.  Here is a quick test form to show the above working:

    http://form.jotformpro.com/form/50495369312963

    I think something like this may be what you are looking for.

  • systemserenity
    Replied on February 20, 2015 at 9:54 AM

    So, question is... If I have:

    - day

    - month

    - year

    Can I perform a calculation somehow to "build" an actual date format field with those numbers?

    Because I would put today's year in there...

    They supply day and month...

    And I could compare the date that is created with today.

    Is the date created greater than or less than today.

     

    But I need to be able to define their birthday this year as a date.

  • KadeJM
    Replied on February 20, 2015 at 12:31 PM

    As my colleague mentioned our form calculations to update values into other field inputs may be able to generate it. I think we might now have a better understanding of the workflow you are seeking even though it's a little bit hazy.

    Currently, I am under the impression that you want to try to figure out a calculation that can generate whether the birth date was this year or the last if that is correct?

    So it'd be something along the lines of...

    Field 1 = Today's Date [2-20-2015]

    Field 2 = They put in say "1-2" for the day first and month second

     

    My current problem with the above though is that I am trying to figure out how would you find if it was this year or last without another year or some other calculation in the mix to represent that.

    If you try to figure out their "birthday as this year as a date" technically I would think you would need to already know or have them input it as this year ie - "2015".

    We'll need a better example to go off of otherwise it is pretty much guesswork and may not be how you are currently envisioning it. Either way though I'll need more time to think of this and I will try to play around with it to see what I can come up with.

  • systemserenity
    Replied on February 20, 2015 at 12:40 PM

    In the form referenced, I have a field called this year that is hidden and is conditionally populated based on "today's date" being between Jan 1 and Dec 31 for several years.

    It is currently 2 fields...

    they enter the day

    then they enter the month

    and the current year is calculated based on the conditions above.

    You can see my form hidden fields by clonin, or do I need to unhide them for you?

    http://www.jotform.us/form/50153884576160

  • David JotForm Support
    Replied on February 20, 2015 at 2:19 PM

    So basically, you want to have two calculations.  One that is performed if their birthday has already occurred this year and one if their birthday has not happened this year.  For this, you would use "today" in your condition.

    Comparing dates Image 1 Screenshot 30

    Comparing dates Image 2 Screenshot 41

    So if they select before todays date, it will enter 2014, if they select after todays date, it will enter 2015.

    Here is my test form:

    http://form.jotformpro.com/form/50495369312963

    Pretty sure this is what you are trying to do.