# Date functions not evaluating consistently

**URL:** <https://forum.inductiveautomation.com/t/date-functions-not-evaluating-consistently/2347>\
**Category:** Ignition\
**Created:** [November 15, 2010, 9:12pm UTC](https://forum.inductiveautomation.com/t/date-functions-not-evaluating-consistently/2347 "2010-11-15T21:12:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrussell](https://avatars.discourse-cdn.com/v4/letter/p/848f3c/32.png) [@patrussell](https://forum.inductiveautomation.com/u/patrussell)\
**Post date:** [November 15, 2010, 9:12pm UTC](https://forum.inductiveautomation.com/t/date-functions-not-evaluating-consistently/2347/1 "2010-11-15T21:12:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dravik](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@Dravik](https://forum.inductiveautomation.com/u/Dravik)\
**Post date:** [November 15, 2010, 9:55pm UTC](https://forum.inductiveautomation.com/t/date-functions-not-evaluating-consistently/2347/2 "2010-11-15T21:55:22Z")

</div>

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.
