Working with time

Looking for some direction. im trying to make a reservation form and would like a user to pick a date and time then pick a duration then using the time/date and the duration create a end date so i can store in db then push to calendar view.

04/17/2024 03:00pm + 90min = 04/17/2024 04:30pm?

BUMP… Looking for some direction on this hurdle. If anybody know how to address i would be extremely gratfull.

Hey @rjp this can be done using a formula field

In this example, I’m using a formula field Created At + Duration to add the Duration field to the Date Time in created at

The formula look like this:

TODATE( {created at}  + TIME(0, 0, {Duration} ) )

There’s 3 parts to this.
Firstly, all Noloco formulas work the same way they do in Excel, so typically you can search for similar solutions in excel.

To add time to a date time in excel, you simply add the time in minutes.

Do 12/02/2024 + 90 would be 12/02/2024 01:30

So we can do the same, but we first need to convert the duration (which is stored in seconds) to minutes, or a time field for even more convenience.

TIME(0, 0, {Duration} )

This passes the Duration field into the seconds argument of the TIME function.

{created at} + TIME(0, 0, {Duration} )

This then adds that time to the created at Date Time.

Finally, you need to convert that date value back to a Noloco Date
This is mentioned in our guides on using Dates in Formulas

TODATE( {created at}  + TIME(0, 0, {Duration} ) )

You can replace created at and Duration with your own fields

2 Likes

Thank you so much. Ill give it a shot.

Not quite their but close? I cant get the formula field to be date time as in your example.


Try creating a brand new field instead of editing an existing field - I don’t think we always (correctly) re-type the field when it’s a formula.

The formula itself looks correct