Date functions not evaluating consistently

The script below is being used to set up a database connection based on a selected date on a calendar object. The comparison between the dates is not evaluating the same every time it runs and is often evaluating incorrectly.

The print statements are for my debug efforts.

Is there something I am doing wrong?

[code]if event.propertyName == “date”:
print event.propertyName
from java.util import Calendar
cal = Calendar.getInstance()
cal.add(Calendar.DAY_OF_YEAR, -2)
olddate = cal.getTime()
date = event.source.date

print olddate
print date

if date < olddate:
	print "Archive"	
	event.source.parent.getComponent('Label 10').text = "Archive"
	event.source.parent.getComponent('PassData').Database = 'L_PROC_DATA'
	event.source.parent.getComponent('PassData').TableName = 'COIL_PROC_SUMMARY'
else:
	print "Active"
	event.source.parent.getComponent('Label 10').text = "Active"
	event.source.parent.getComponent('PassData').Database = 'Tmill'
	event.source.parent.getComponent('PassData').TableName = 'RTM_COIL_HSIO_SUM'[/code]

Thank you,
Pat

I’m not sure you can do a greater than or less than on a date reliably.

I would convert the dates into unix seconds or cast to int and do the compare that way.