I have a boolean memory tag which I use to fire off a script. I am using the dateExtract() function to compare against hours in the day I would like the tag to go high. I finally got the expression to work but by accident, removing the open parenthesis. Here is what I have:
The reason the second expression you note did not work is you are missing closing parentheses for all the opening parentheses before all but the first dateExtract (highlighted with asterisks below). Every opening parenthesis requires a matching closing parenthesis.
See Ignition Expression Overview and Syntax and refer to Ignition Expression Functions for details on specific functions available. If something doesn’t work, comment out everything except the innermost part and test that. If that works, add in another piece and test again. Repeat until you find the problem. It’ll often be a missing comma, parenthesis, or argument.
You can nest expressions in multiple branches to create complex logic when required. Scripting is also an option in expressions (via runScript), but this case was simple enough I don’t see any reason for scripting. Complex expressions are much easier to follow if you organize them with indenting (something like I’ve done above), and–in some cases–break them down into simpler expressions on separate properties or tags that are then used in the final expression.
An alternative way is to create intermediary values in your tags or custom parameters.
In the example given, you could create intermediary values like isFirstSecond, isFirstMinute and is4thHour and use these in your final expression.
This will allow you to check the intermediary values, and see where it's going wrong. It may be overkill for an expression that only turns out to be 5 lines long, but for more complicated ones, it's certainly worth it.
PS. you don't actually need the check on the seconds, and not even on the minutes. If you just check every forth hour, at the start of the hour, the tag will become true and fire the script. But it will remain true for the rest of the hour, so it will not fire any other scripts.
I'd even say that checking the seconds can be dangerous. If there are performance problems on your system, you can get a clock drift of a few seconds, and that will mean a few seconds will be skipped.