Using Jython Script to Iterate through a date range

I have a date range using two strings: startDate and endDate.

I want to write a script to iterate through each and every day between the startDate and endDate, inclusive. The version of Jython in Ignition doesn’t support the datetime library. I have looked into using an import of java.util but don’t get very far when trying to convert the string to a java Calendar object.

The reason for this script is to be able to iterate through a date range and for each day in the range do a historical tag query with a specific time range. Currently the system.tag.queryTagHistory function does not a where clause to filter each day by a time frame so I am forced to iterate through each day in a date range.

Thanks.

Just to be sure: you’re on 7.3 or earlier then right? 7.4 and later use Jython 2.5, which does include datetime.

Yes, I am on version 7.3.

I think I figured it out.

Glad you got it figured out. Let us know if you need any additional help with this.

You could always create a calendar table in the database and query it for the dates. It’ll return a dataset with all the dates, that’s easy to iterate through.