Page 1 of 1

Compare DATETIME values???

Posted: Wed Aug 02, 2006 4:49 pm
by seodevhead
I have a column in a table that is of the DATETIME type. And whenever a record is inserted, that DATETIME column is assigned NOW() within the INSERT query.

I am now writing a script that should be able to determine if one record in this table was created before or after another record by using the DATETIME column.

For instance:

Code: Select all

if ($row1['date_entered'] > $row2['date_entered'])
Problem is, it doesn't seem to be working. It seems as though you can't compare DATETIME values (ie NOW() values) together. Can you? If not, what is a simple solution to this problem so I can compare two DATETIME values and see which is the earlier record. Thanks so much for your help.

Posted: Wed Aug 02, 2006 4:55 pm
by feyd
seodevhead wrote:Can you?
Yes, you can.

Posted: Wed Aug 02, 2006 5:00 pm
by seodevhead
Man thanks a ton feyd.. that makes things soooo much easier. After you told me that I can indeed compare DATETIME values... I took a closer look at one of the two queries and found that I was calling the DATE_FORMAT'ed column and not the original. Can't believe I didn't catch that on the first couple re-overlooks...Viola... it works. Thanks a ton buddy.