Date Time component min time not working when there's a min date

Hi Retool Community,

Can anyone please help me here?

  • Goal: My goal is to have two date-time components: From and To, using the date-time component. Users can only select times between 10 PM and 6 AM. They cannot select a date earlier than the Start date. For example, if the Start date is 02/25/2025, they cannot select 02/24/2025 or any earlier date. The End date can only be the day after the Start date, meaning 02/26/2025 if the Start date is 02/25/2025.

  • Steps: The min time and max time work perfectly, but when you add the min date, the min time stop working.

  • Details: I added two date time components. The From is limited to 10pm to 6am using the validation min time and max time. From is working correctly.

But when I do the same for my To component, it works initially, but when you add the min date, the time now starts at 12am instead of 10pm.

They should only be able to select 21 or 22 if From is 21, and the time range should be 10pm to 6am.

Thank you!

We can mark this as solved.

My solution was to set the Min Time of To into:

{{ moment(dateTimeFrom.value).format("YYYY-MM-DD") === moment(dateTimeTo.value).format("YYYY-MM-DD") ? dateTimeFrom.value : "" }}

Max Time into:

{{ moment(dateTimeFrom.value).format("YYYY-MM-DD") === moment(dateTimeTo.value).format("YYYY-MM-DD") ? "" : "6am" }}

Now, when it's the same date, they can only choose up to 11:30 PM

and if it's the next day, they can only choose 12am to 6am:

2 Likes

Updated Max Time for To to support same date and times between 12am to 6am:

{{ moment(dateTimeFrom.value).format("YYYY-MM-DD") === moment(dateTimeTo.value).format("YYYY-MM-DD") ? moment(dateTimeFrom.value).format("A") === "AM" ? "6am" : "" : "6am" }}

image