Compare date from drop down calendar to date in dataset

I am trying to manipulate a dataset in factoryPMI. I have a dataset that has a date column, a start date calendar component, and an end date calendar component. I would like to have a button that can be pressed that will take only the rows in the data set that have a date between the start and end date. The resulting rows will then be displayed in a table.

The problem I am having is the if statement to see if the date from the row is between the start and end.

for row in dsPyData:
	startDate = event.source.parent.getComponent('calStart').date
	endDate = event.source.parent.getComponent('calEnd').date
	if(row["Date"] > startDate and row["Date"] < endDate):
		print str(row["Date"])+" > "+ str(startDate)+" and "+str(row["Date"])+" < "+str(endDate)

this is what i am getting for output:

Tue Feb 03 00:00:00 PST 2004 > Mon Dec 01 00:00:00 PST 2008 and Tue Feb 03 00:00:00 PST 2004 < Tue Mar 10 00:00:00 PDT 2009
Mon Mar 17 00:00:00 PST 2003 > Mon Dec 01 00:00:00 PST 2008 and Mon Mar 17 00:00:00 PST 2003 < Tue Mar 10 00:00:00 PDT 2009

Sounds like Jython doesn’t know how to compare Java dates. Get the raw “time” out of the data (milliseconds since 1970) and compare that instead:

for row in dsPyData: startDate = event.source.parent.getComponent('calStart').date.time endDate = event.source.parent.getComponent('calEnd').date.time if(row["Date"].time > startDate and row["Date"].time < endDate): print str(row["Date"])+" > "+ str(startDate)+" and "+str(row["Date"])+" < "+str(endDate)
Hope this helps

yes that works.

thanks