Jump to content

[SOLVED] PHP: Only output rows with todays day???


webmaster1

Recommended Posts

if you do not want to work with date, change the date into number@decimal..

example <?php echo $d= date ('Ymd'); ?> will return 20092202...

then use explode() to remove "-" in your date... so your date will be a number

use the sql that your just create earlier..

select * from tablename where scheduledate <= '$d'

 

but it only a suggestion if you had face difficulty using function date in php..

that all..bye

Hi

 

Or keeping it in SQL:-

 

select * from tablename where scheduledate < date_format(date_add(now(), INTERVAL 24 hour),'%Y-%m-%d 00:00:00')

 

Basically add 24 hours to the date / time now, then just use the time of 00 and check the date is less. Should reduce the need for manipulating all the individual dates on the table.

 

The date formatting can probably be cleaned up.

 

All the best

 

Keith

Hi

 

Using DATE() on NOW() isn't really going to do much unless you do the same for every date time field you want to compare against which is an unnecessary overhead. Hence my suggestion to convert the current date time to be the very start of tomorrow and then compare that against stored date / time field.

 

All the best

 

Keith

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.