Comparing 2 date fields

Please help me on this one. Should be easy for you guys, but I feel like giving up.
I have to compare between 2 date fields. One field automatically generated from a table, and the value is filled manually.
The other one, I manually added date field, and the value is filled on load event by mysql query.

If dateField1 > dateField2, sc_error_message should be displayed.

Can you please tell me the correct way to do it? I keep getting the error message even though dateField1 < datefield2.