Skip to main content

๐Ÿ“… Calendar vs Date Form Elements ๐Ÿ“†

Summary

Generally, Slate stores date values in custom fields as text, even when the field datatype is set to Date.

  • The Calendar form element (jQuery Datepicker) stores dates like yyyy-MM-dd.
  • The Date form element (a group of three select elements) stores values likeย yyyyMMdd.

This causes some strange issue when storing and retrieving data via forms and widget tables. Queries generally use SQLโ€™s try_cast() and function fine. We can work around the form issues with a few tricks.

Related Forum Post (๐Ÿ” requires login)

If you stick with one input style (calendar vs date) for a particular field, you won't have problems.

Using default value formulas can also help if data coming via a Source Format isn't formatted the way Slate expects.

Using a Date field in an Entity pop-up widget to edit a date saved by a Calendar will cause the existing value to pre-populate incorrectly. See results of trying to use a drop-down date field widget to edit a value originally set by a calendar (Datepicker) widget:

form date element.png

Date Fields

To ensure that Date form controls work correctly, use a Default Value Formula:

default value formula.png

Set the Format Type to Date and the Format Mask to yyyyMMdd.

format mask.png

Calendar Fields

As above, use a Default Value Formula, but this time, set the Format Mask to yyyy-MM-dd.

You may also be able to leave the Format Mask blank, as it should default to the above format which matches the SQL Server default date format.