The solution to extract end dates with conditional rules

I would like to extend the article of How to Extract the Start and End Dates from a Date Field that you can find in this url:

https://support.knack.com/hc/en-us/articles/360015346072-How-to-Extract- the-Start-and-End-Dates-from-a-Date-Field

We can extract the final date of a field with a start and end date format using different text formulas.

But depending on the type of date the user entered, one formula or another should be used.
Knack does not allow us to use conditionals in the text formula fields, so we have to use this method to extract the final date in any input date format.

  1. We must create a text formula type field to calculate the length of the date field entered in the form.
    The formula is:
    length ({data_event})

ok, now knowing the length of the date field we know what type of date format the user has entered:

  • If there are 10 characters, we know that you have chosen a date of type full day with start and end the same day
  • If there are 24 characters, we know that you have chosen a date of type full day with beginning and end in different days.
  • If there are 25 characters we know that you have chosen a date / time type with start and end the same day
  • If there are 36 characters we know that you have chosen a date / time type with beginning and end in different days

2. Now we will create 3 fields of type text formula with the 3 types of possible formulas to extract the final date.
For example:

  • End_Date_10_25 with the following formula: left ({date_event}, 10)
  • End_Date_24 with the following formula: right ({date_event}, 10)
  • End_Date_36 with the following formula: mid ({date_event}, 20.10)

3. And the final step will be to create the date field named "end_date" which will have some conditional rule:

When Data_length is 10 Set a record value End_Date_10_25

When Data_length is 25 Set a record value End_Date_10_25

When Data_length is 24 Set a record value End_Date_24

When Data_length is 36 Set a record Value End_Date_36

And that's all, Finally we have our final date