Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.