Use Case
If you need to showcase a date field in various formats, here's how you can do it.
For example, let’s say that you’re accepting registrations for an event and want to show the date of the event in the following formats:
On the event’s information page for international attendees |
21/7/2018 at 7pm |
On the reminder email for the event |
Saturday, July 21 at 7:00pm |
On the receipt for the event |
07-21-2018 |
Requirements
If this is your first time creating an app, you'll need to know some basics about adding tables, fields, pages, and views. Other good resources are the About Your Database and Working With Pages articles in the knowledge base.
This date formatter is available in text formulas. Click here for information on text formulas.
Steps
Create a Date/Time Field
If you don’t have one already, create a Date/Time field in the Events table.
In this example, we'll use the Date/Time field “Event Date”:
Format Date for International Attendees
Now that you have a Date/Time field, you can start creating the different date formats you’ll need.
First up is the date format you want to use on the event’s information page for international attendees: 21/7/2018 at 7:00 pm
-
Create a text formula and name it “International Date Format.”
-
Use the following formula:
-
formatDate({Event Date}, D/M/YYYY [at] ha)
This is how it will look in the Builder:
This is how it will look in the Live app:
Format Date for Reminder Emails
Next is the date format you want to use on the reminder email for the event:
Saturday, July 21, at 7:00 pm
-
Create a text formula and name it “Reminder Email Date Format.”
-
Use the following formula:
-
formatDate({Event Date}, dddd, MMMM D [at] h:mmA)
This is how it will look in the Builder:
This is how it will look in the email:
Format Date for Receipt
Finally, the date format you want to use on the receipt for the event. For example, 07-21-2018.
-
Create a text formula and name it “Receipt Date Format.”
-
Use the following formula:
-
formatDate({Event Date}, MM-DD-YYYY)
This is how it will look in the Builder:
This is how it will look in the Live app:
More Date Formats
The formats included in this article only cover a few of the date formats you can create.
To create other formats, take a look at the other date formatter output options in this article: Date Formatter.
Notes & Troubleshooting
Populate a text formula with values
Once your text formula is created, the values in this field will automatically populate.
Depending on the number of records in that table, it may take just a bit of time. If you don't see the values populate immediately, give it a few minutes and come back to that table's records. Please contact Knack support if these field values continue to stay blank.
Scenarios where text formulas can’t be used
There are a few situations where text formulas can’t be used:
-
Not available on forms
-
Unable to reference fields with a "many" connection (since there are many values connected and text formulas can only pull in a single value)
-
A connection field in another table