This should probably be a Gateway Scheduled Event Script.
Either way, I just learned about a better way of doing this:
Note that unless you have filtered the code prior to the code you shared, it will execute when the value changes, but also when the quality changes, so you probably want to insure that the value has actually made a False to True transition.
Also, verify that your Gateway, Database, and Local machine all have the same Date Time settings.
Put in on a gateway timer script to check hourly with fixed rate set. Also check for time at the hourly level vs down to a minute. See the post @lrose shared.
I assume the issue with your script which checks the time and where it is located. Wherever it is located is not checking or triggering correctly. I would try that script in the script console.
I have changed the expression boolean tag to different time values and it becomes true between the new values. I have also put the the script in the console ant returns look correct.
This sounds like a time difference issue. If you pull the historical data and manually convert the t_stamp using the same settings that the Gateway is using, is it in the correct time?
Is the gateway for any reason in a different time zone than the database? This just feels like a time zone conversion issue.
After alot of checking and double checking, I have noticed that the script is running at the time I want it to. BUT the time range on the power chart is off for whatever reason. Should I use a time series chart or something else for a more accurate time range display? Or us there some other reason that that time is off? Thanks alot for the help.