DateTime Picker defaulting only the time

I’m trying to set only the time in the picker to a default value. Right now, the value stays null until the user selects a date, but the time is defaulted to midnight. 99.99% of the item, users interacting with the component will need to look at any date with the time of 07:00:00. Eliminating the requirement to select the date AND change the time from midnight to 7 am is the goal. I’ve tried some script transforms with no success. To summarize:

Value is null until user selects a date. Once date is selected, default time is 07:00:00.

Thank you in advance.

  • 99.99% of the time

Have you tried using a change script on the value?

I would bind the datepicker value to:
toDate(dateFormat(now(0), 'yyyy-MM-dd 07:00:00'))

The binding will execute once upon opening.

1 Like

Will that not change the value to today’s date, without the user selecting it? I want the value to remain null until the user interacts with the component.

I need this to be 07:00 AM when the user clicks the selector

Consider using the time span embeddable view from my Tag Report Utility (in the exchange). It breaks out separate time entry fields according to the interval selections the user makes, and presets start time/end time when using day boundaries.

This may be the way to go. I’m having a hard time with it not constantly applying the change. It cycled from a selected date of today to the year 2180 in a few seconds

Note that the embeddable view's parameters are mostly bidirectional, so the defaults for interval, bounds, and start/end are expected to be supplied by the containing view.

Got it

Spoke too soon, the user can’t override the change script by selecting a different time.

What if you check if is None?

If currentValue.value is None:

 Your script here

It needs a legit dateTime value to apply the setTime function to. Might need to do this on session start up instead of the components value property change

This seems way more complex than it should be. There must be some simpler way to have the component start at a time of 07:00 AM instead of 12:00 AM

Tried with previousValue.value is None:

script here

it gives me an error. I guess it needs to see an actual previous value to execute the script

I don’t understand the necessity of this. In any case, I tried both scenarios:

  • The value is None, and on the first date selection the time is initially set to midnight and then changed to 07:00.
	if currentValue.value:
		self.props.value = system.date.setTime(currentValue.value, 7, 0, 0) 

The value is None, and on the first selection the time is already set to 07:00.

    if currentValue.value and previousValue.value is not None:
        self.props.value = system.date.setTime(currentValue.value, 7, 0, 0) 

Here the examples:

Did you try changing the time from 7 am to something else after selecting the date?

No I didn’t understand that needs. Sorry, I can’t try at the moment

Here’s what I’ve been able to do so far:

Created an onstartup even that sets a custom property to 1 when the view loads

created a property change script on the components value that if custom view property equals 1, force the time to 7 am when a date is selected, and then set the custom view property to 0.

The limitation with this, of course, is that any other dates selected after the first one, the time defaults back to 12 am.

forgot to make start and end pickers use unique view properties in their scripts.