Jump to content

Help on MySQL PHP dates


gnawz

Recommended Posts

Iam using PHP 5.2.3 and My SQL 5.0.45

 

I need to select database details where the date is today.

My MYSQL date type is DATETIME.

I know if my MYSQL date type is DATE I do it thus;

<?

$sql = 'SELECT * FROM cstocksales WHERE Date = CURRENT-DATE';

?>

 

AND it works

But how do I do it with a date data type that is DATETIME, ie return results with current data and its time when a sle was made?

Link to comment
https://forums.phpfreaks.com/topic/118756-help-on-mysql-php-dates/
Share on other sites

I need to do the comparison (generate a report) from a MySQL date field whose data type is DATETIME..

 

Meaning it displays date and time as opposed to data type DATE which displays only the date.

 

Did you try it?  My example compares dates, not times:

 

... WHERE DATE_FORMAT(Date, '%Y%m%d') = CURDATE();

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.