Skip to main content
Modifying Dates with Lua Calculations

How to use Lua to modify date fields

Angela Lim avatar
Written by Angela Lim
Updated over 5 years ago

Using the date  keyword, you can convert a date selected in a Date field into a formatted text to use elsewhere in a form.

Use the line below to access and format a date field:
​ 
date ("%x", answers.date_field)
 

...where %x is how you want the date to be formatted, and date_field  is the slug of the Date field in your form.

Date Formats

Examples:

date ("%m%d%y", answers.date_of_birth)
=> If 03/07/2019 is selected in a date field, this would output "030719"

date ("%m%d%Y", answers.date_of_birth)
=> Same as above, but prints the full 4-digit year "03072019"

date("%x", answers.date_of_completion)
=> If 03/07/2019 is selected in a date field, this would output "03/07/19"

Did this answer your question?