Jump to content

[SOLVED] MySQL query searching for future date


bsamson

Recommended Posts

Alright I currently have this code:

 

<?php
mysql_query("SELECT * FROM v2callbacks WHERE DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%Y/%m/%d') = '2008/05/13'")
?>

 

How do I change this section:

DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%Y/%m/%d')

 

to add 15 days to the entrydate field? Not change the field BUT take the entrydate and add 15 days.

 

Thanks in advance!

Link to comment
Share on other sites

hmmm ... when I run the following query ... it doesn't appear to error out. Any pros and/or cons?

 

<?php
mysql_query("SELECT * from v2callbacks WHERE DATE_ADD(DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%Y/%m/%d'), INTERVAL 15 DAY) = '2008/05/13'");
?>

 

Thanks again...

Link to comment
Share on other sites

Thanks for the input. But it doesn't appear to be working. Via phpMyAdmin I am running this query:

 

SELECT * from v2callbacks WHERE DATE_ADD(DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%m/%d/%Y'), INTERVAL 15 DAY) = '05/28/2008'

 

I have a field that I set the entrydate to: 1211995559 (which is 05/28/2008)

 

However, phpMyAdmin reports:

MySQL returned an empty result set (i.e. zero rows). (Query took 0.0004 sec)

 

Any suggestions?

Link to comment
Share on other sites

Thanks for the input. But it doesn't appear to be working. Via phpMyAdmin I am running this query:

 

SELECT * from v2callbacks WHERE DATE_ADD(DATE_FORMAT(FROM_UNIXTIME(`entrydate`), '%m/%d/%Y'), INTERVAL 15 DAY) = '05/28/2008'

 

I have a field that I set the entrydate to: 1211995559 (which is 05/28/2008)

 

However, phpMyAdmin reports:

MySQL returned an empty result set (i.e. zero rows). (Query took 0.0004 sec)

 

Any suggestions?

If you are adding 15 days, the entrydate would need to be 5/13/2008 to get a match on 5/28/2008

Link to comment
Share on other sites

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.