Contentful logo

Contentful Community

Date Ranges & Recurring Dates

What would be the recommended way to handle a date range field? I am currently considering two fields (1. Start Date 2. End Date) but these fields are not aware of each other and I’m unsure how to validate that the end date is later than the start date.

Additionally, curious how one might handle recurring dates in Contentful.

Hi Blake!

Date fields just don’t know about each-other so it’s not possible to have such a validation. One approach could be using an UI extension for this, so the extension would have to be aware of the other field, do the validation, and notify the user.

Additionally, curious how one might handle recurring dates in Contentful.

You mean like an event that is happening e.g. every week on a Monday? or an event that happens on two or more specific dates? I guess you could use the Object (json ) field type to model something. Alternatively you could model something using the Array<Link> field type and link to entries of a content type created specifically for this. E.g. each linked entry could represent one date or day of the week.

Best,
Daniel

1 Like