Change date/time values

Let’s say I have two datetime fields. Whenever I set the first field, I want the second field to adjust to the same date, but one hour later. Is this possible? The Java script itself is not the problem, I just can’t figure out how to ‘plug into’ the Skuid page that contains those fields.

What about a UI only formula field set to the date time field plus 1 hour?

Thanks, I started reading on UI only formula fields. I understand that they react to input into another field. However, and this is another requirement, my first datetime field should populate automatically to current date and beginning of the next hour. So, if now we have 10/5/2017 3:20pm, the first field should display 10/5/2017 4:00pm when the page loads. Is that possible?

Setting it to the current datetime is easy. Setting it to round up to the next hour is hard. I think you would need JavaScript which is not my specialty.

I would really appreciate it if  you could tell me how to set it to the current datetime. I can write the Java script, but I have no experience with Skuid and… I am reading a lot on it, but still haven’t figured out exactly how to put values into fields. Sure, I found examples, but so far I couldn’t implement any of them successfully.

To set a field to a certain value on page load, put a condition on the model where the datetime field = now.

I can’t find where to do that. This is a screenshot of what I have there: https://imgur.com/a/X9f0t


There is a separate section under models labeled “conditions”. You are in the fields section of the model.

I found it, clicked the plus sign and go [No Field] like in the screenshot. I can’t edit it though. https://imgur.com/a/YHgMN

When “no field” is highlighted, look to the right. There is a separate pane that allows you to set the condition.

Thank you very much! I have two fields, start date/time and end date/time. Start date would display beginning of next hour (as in now it’s 8:20am and it should display 9:00am), and end date one hour later than start. Would I need to use two UI only formula fields?

Yes, but remember that UI only fields don’t save the values you enter into them in the database. Their content disappears when you refresh the screen so I’d you want to save the times in the UI only fields to your database you will have to use a model action that sets the database field equal to the Ui only field when the model is saved.

I read that about UI only fields, but wasn’t sure if I got it right… I understand what you’re saying about saving those fields, now I have to figure out how to put into practice.

Another way to do it would be to have a button set to run multiple actions. The first two actions would save the UI only field values to the database fields then the last action would be to save the model.

Hi Raymond - jumping in here (NIck’s coworker, SF Admin)…do you know how we’d set the UI Formula field(s)?  I’ve gone down that path (was my first thought), but never could figure out how to write it in Skuid.  (I had seen something else that seemed relevant that mentioned Java, which is why I pulled Nick in, since I’m declarative only.)

Essentially, it’d be something like “NOW() + 60 MINUTES”, but I could never get that quite right (not sure it if needs to be in minutes, or seconds, or a fraction of a day, or…?)  I’m less concerned about getting the Start Date Time to round up to the next hour (currently, I have it set to start at NOW), and more focused on getting the End Date Time to push out Start + 60 minutes.  (Because my users don’t like having to click 6 different fields - by the time they fill in Start Hour/Min/AmPm…and then End Hour/Min/AmPm.)

Once I get that, I’m pretty sure I can figure out the actions to push the UI-only value to the “real” Start and End Date fields…definitely done some of that in the past.

I’d love to be able to do just an action on the model that says “When record created, update the Start Field with NOW + 60, and End Field with Start + 60” (or whatever), but the only options for that are “today, yesterday, n days ago, n months in the future, etc”…nothing that gets down to a minute or hour level.  :frowning:

This may shed some light on using UI only to calculate dates. https://community.skuid.com/t/calculate-age-with-ui-only-field