Command Shell: Be careful with Date-Time criteria and calculations

Nathan left a comment on one of my posts the other day.

See thread:  Is alert grooming working?

Well, Nathan helped me find a problem with my script.  The problem was the Date-Time criteria I was using for my calculations to verify whether or not Alert Grooming was working.  This script worked as expected, but the results were not foreseen.

The issue was, I wasn’t taking into consideration the time zone difference in the Date-Time calculation.  Operations Manager, just like most every database driven application, stores data in GMT.  This skewed the Date calculation.  The further away from GMT time zone you are, the more skewed the results were, depending on what time of the day you ran the script.

So, if you’re in Central Time Zone (GMT-6:00) and you run this command on 01/01/2009 @ 7:00PM, the result may be misleading or false.  The script will include data items for 01/02/2009, up to 1:00AM.  If DT is converted to Date (which happened to be the case in this one), then data items only from 01/02/2009 would have been returned.

This is now fixed in my example script.

It just so happens I use Date-Time criteria and calculations in a few other examples on my Command Shell main page.  There were only a handful that needed to be updated, and I ran through those tonight and fixed them.  Let me know if I missed any!

Comments (0)

Skip to main content