First, what is the intent of this first expression?
SET_DATETIME_COMPONENT(privateVars.selected_date, GET_DATETIME_COMPONENT(privateVars.selected_date, “date”),“date”)
This appears to have no effect since it extracts the date portion of privateVars.selected_date and then surgically reinserts this as the date of that same variable. Probably not what you intended.
Keep in mind that && is really just an AND for compound boolean expressions. Using && as a way to perform multiple functions in the way you’re doing it will only behave in a useful way if the following two things are guaranteed:
- Each sub-expression has a value that is interpreted as TRUE (if a FALSE is encountered, the entire expression is known to be FALSE and the rest don’t need run or evaluated)
- Each sub-expression has to do something useful on it’s own. It’s return value is meaningless and just has to be TRUE (as stated in 1) to keep running all the following sub-expressions
SET_DATETIME_COMPONENT() always returns a datetime, so I think 1) above is satisfied.
But that function doesn’t modify the variable you provide, it returns the modified datetime as the return value. Each of the SET_DATETIME_COMPONENT(), assuming they all get run, start with the original privateVars.selected_date, modifies it’s one piece, and then throws that away. Or maybe one of them gets used as the variable assignment, but I don’t think that’s what you were trying to do.
Reading between the lines, it seems what you want to do is take a datetime and modify the date, hour, and minute with new values, and then assign that to the variable. The way I would do that is to nest your 3 functions so that the result of each modification is fed into the next function, whose result is fed into the next function, etc. The result of the final function is used as the value to assign to the private variable.
Something like this (shown on multiple lines for clarity – collapse these into 1 line when entering, of course):
SET_DATETIME_COMPONENT(privateVars.selected_date, newDate, “date”),
Where newDate, newMinute, and newHour are numeric values that you want to use as the replacement values in the datetime value. Replace these with the values you really want to insert.