Change in function capability or a possible bug in RM Set Variable

It appears that the capability for how the RM "Set Variable" -> "Set Time and/or Date" function works.

The expected capability is that if a DateTime variable is already set with values, a call to this function would bring the current values of the variable and the existing time "and / or" date could be adjusted with this function. This is also how it used to work in some prior version. Just discovered the difference when I got around to troubleshooting a rule that stopped working at some point.

Currently, if only a time is entered, the whole existing value of the date and time variable is overwritten with just the time (i.e. the date is erased).

How to recreate:

Action 1: Set Variable -> [Date/Time Variable 1] -> Current Date and Time = Works as expected
Action 2: Set Variable -> [Date/Time Variable 1] -> Set Time and/or Date -> enter only the time = Variable is set to only have a time (i.e. the date is erased)

See Action list with result:

image

This used to result in the "Current_Date" variable being set to: 2023-10-14 12:00AM

Is this a bug or just a change in the capability of this function?

If it's a change, how do we set just the date or time, and keep the rest of the DateTime already entered?

EDIT:
I'm on platform version 2.3.6.144

This is expected AFAIK. I think the date time variable has changed some over time, but this change as been in effect for a bit now I think,

Thanks for the workaround idea. Much appreciated!!

I edited the original post to indicate I'm on platform version 2.3.6.144

Somewhere along the way, the Rule Machine updates also changed the format of the %date% to be used to set a variable. I have been using a token strip of "-" to get the components of the date (MM, DD, YYYY) in a lot of rules associated with DateTime, and just had to adjust them all to deal with it.

The working method to get the year from a date used to be:

Set Variable_2_Date with token(2) delimited by '-' from 'variable: Variable_1_Date(10-23-2023)

This is now:

Set Variable_2 with token(0) delimited by '-' from 'variable: Variable_1_Date(2023-10-23)

You might be thinking that there is a field in Rule Machine to indicate how the %date% field should be displayed, and there is:

but it doesn't appear to stick over time and keeps reverting to the YYYY-MM-DD format. So it was simpler and less frustrating to just adjust all the token indices in the rules...

If this is now expected behavior, it makes it quite cumbersome to update a DateTime variable with individual components, which is needed in a number of circumstances.

@bravenel

Can you please advise if this is expected behavior, and if it is, can we please consider adding a feature to be able to preserve prior DateTime values when updating a single component of the Date or Time in a future update? Would also be good to be able to update these individual Date and Time components with the the value of a different existing variable.

Thanks!

You need three options. I have some variables where I only want date and some where I want time and some both. There is an option to fill a variable with any of the three, to me that seems the best option.

I will look into this. Perhaps the best solution would be for the current date and/or time be pre-populated into the action template:

Then it becomes clear what to expect, including the possibility of erasing either the time or the date when that is needed.

Agree this is the behavior I was expecting, and think it used to do in the past, but maybe via a different screen format? I can't remember exactly, but would be great.

While you're looking at it, any chance to be able to select a variable for each component?

Much appreciated!!

I've been looking into this. To do what your original post wants to do would require two new actions to be implemented: Set ONLY Time and Set ONLY Date. It must be possible to clear the time or date in a DateTime variable with an action -- that's the current functionality as you observed.

These new actions will be added to the 2.3.7 release.

4 Likes

Great! Appreciate the effort to look into this! Can you help me understand a little more how the new actions will behave?

Set ONLY Time:

  • If you select an unpopulated DateTime variable, will it allow you to set the time without entering any date info? I'd assume this is kind of the behavior I see now when I only enter the time in the "Set Time and/or Date" action, which then just displays a time after the action.
  • If you select a DateTime variable that is already populated, is the time portion set per the action and the date remains unchanged?

Set ONLY Date: Same questions as for Time but only for Date portion.

Also, given the way the current "Set Time and/or Date" action works, I'm wondering if it should be renamed to "Set Time and Date", as both of these components of the variable are always updated, even if only one is entered (clearing the data for any component left blank from the action).

There is no such thing as an unpopulated DateTime variable. Hub Variables requires every created variable to be set to some value.

Correct.

While both are "updated", it may be that only one or the other is set. So the current name is appropriate. I think this will be clearer with the new actions.