hi ! Friends
can anyone tell me how to compare date which stored in database with current date and how display latest date in php plse help me ?????????

Member Avatar for diafol

What have you tried so far?

The relevant php and mysql manual pages will probably be:

http://uk1.php.net/manual/en/function.date.php
http://uk1.php.net/manual/en/datetime.construct.php
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format

SELECT field1, field2 FROM myTable WHERE ***

Where *** could be anything like

myDateField = '$date'
myDateField >= '$date' ORDER BY myDateField DESC
myDateField <= '$date'

Your SQL would probably look like...

SELECT myDateField FROM myTable WHERE  myDateField >= '$date' ORDER BY myDateField DESC LIMIT 1

There are variations on a theme - you could use MAX() aqnd GROUP_BY().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.