Store a date in a specific format after entering in another format and doing calculation against it

  • uofm_matt
    Asked on November 18, 2017 at 11:46 AM

    I'd like to enter a date in format MM/DD/YYYY in my form and then be able to calculate against that date, say MM/DD/YYYY - 45 days, and then put the resulting data into a different format, MMM DD, YYYY, in another field.  I need this format, MMM DD, YYYY in the database, versus the standard date and then present it via jotform formatting (say in a jotform email).

  • Richie JotForm Support
    Replied on November 18, 2017 at 1:37 PM

    Hello,

    It seems that the Date-Format available to JotForm forms are as follows:

    Store a date in a specific format after entering in another format and doing calculation against it Image 1 Screenshot 90

    And yes you can calculate the result of a date with conditions.

    To be able to do this we need a short text entry and conditions

    Store a date in a specific format after entering in another format and doing calculation against it Image 2 Screenshot 101

    Place a short text entry in between two date picker then go to settings>conditions

    Update/Calculate Field.

    Store a date in a specific format after entering in another format and doing calculation against it Image 3 Screenshot 112


    IF >the short text entry then make state as Filled after in the Do choose Calculate a field's value add the date field and subtract it with 45 and the summary would be your second date picker

    .Store a date in a specific format after entering in another format and doing calculation against it Image 4 Screenshot 123

    Create another condition and in the IF put your date and state to isFilled, in the DO select calculate a fields value. Click the ... where the date string value can be found.Store a date in a specific format after entering in another format and doing calculation against it Image 5 Screenshot 134

    Store a date in a specific format after entering in another format and doing calculation against it Image 6 Screenshot 145

    Add the date field inside

     Store a date in a specific format after entering in another format and doing calculation against it Image 7 Screenshot 156

    and summary to your short text entry.

    Store a date in a specific format after entering in another format and doing calculation against it Image 8 Screenshot 167

    Hopefully this information helped you.

    Here is the link to my sample form:https://form.jotform.com/73214806889972

    Regards.


  • uofm_matt
    Replied on November 19, 2017 at 10:02 PM

    Apparently this will not submit the date in MMM DD, YYYY format to the database though, no?  If no, can we submit a feature request to put a custom defined date in the database?  Others may have this need for whatever format they want.

  • Kiran Support Team Lead
    Replied on November 20, 2017 at 6:19 AM

    Please note that all the fields available on the form will be storing the data from the fields whatever entered/available at the time of submitting the form. Since the date conversion is being converted on a different field using a condition based on the date entered, the field data will also be available in the form submission data. You may clone the form provided by our colleague to your account and see how it works.

    Let us know if you are referring something different. We will be happy to help. 

  • uofm_matt
    Replied on February 1, 2020 at 5:25 AM

    Bringing this back up again as I have the need again.  dateString() only outputs in the format of Sat Feb 01 2020, I'd like to be able to output to Feb 01, 2020 (or any other date format for that matter like Feb 1 20, or 01-Feb-20, etc, or others).  Can dateString() be modified to allow for specific formatting other than the default?

  • Girish JotForm Support
    Replied on February 1, 2020 at 8:51 AM

    By default, this is the format "Sat Feb 01 2020".

    To clarify you want the dateString function to not show the day i.e. "Sat", etc. Is that correct?

    Do review and let us know. We can check with our back end team if customization is possible to change the format.


  • uofm_matt
    Replied on February 1, 2020 at 8:56 AM

    I'd like to be able to format the dateString, or have other options to format it.  What I'd really like is, at minimum, Feb 01, 2020 (which is MMM DD, YYYY) and 02/01/2020 (which is MM/DD/YYYY).  Thanks!

  • Kevin Support Team Lead
    Replied on February 1, 2020 at 11:28 AM

    The widget currently will show the date like this while using the dateString() function:

    15805741152020 02 01 10h21 40 Screenshot 10

    Now, it's not possible to customize the output date; however, you can separate the needed data and generate your custom date, you can do this with the SubString widget, you may use different widgets to get the day, month and year, you may decide which characters to include and then generate the date using a calculation widget and including all the substring widgets as text. 

    Here's the link to the widget where you can get more details: https://www.jotform.com/widgets/substring

    Please kindly give this a try and let us know if you have questions.