Jump to content

DATEDIFF Question


WendyLady

Recommended Posts

Hi -- I'm wondering about a clarification, because I can't find an answer.

Basically, I'm trying to form a query that will look in the database, find all entries where the difference between a stored date & today is 0 (i.e., whether that date has passed). Another one, similarly, to find all entries where the difference between today & a stored date is <60.

I'm playing around with the mysql DATEDIFF() function, but I can't even get it to tell me what the date difference was (not sure how to return it).

And is it possible to have a query that says "SELECT * FROM xyz WHERE DATEDIFF('now()', 'stored_date')<60" ? It doesn't seem to be working, but I'm not sure if isn't just because I'm not doing it right.

The mysql documentation isn't helping me all that much -- if there is another source, I would love to know about it.

The point of my code will be to make changes to the entries where the stored date has passed, so would it be easiest to select all where stored_date < now()? I'm playing around with it in lieu of finding anything illuminating . . .

Thanks --

Wendy

--If I ever figure out dates, I'll be SET!
Link to comment
Share on other sites

[code]

<?
$data1 = mktime (0,0,0,5,5,2005); //specify a date1
$data2 = mktime (0,0,0,5,15,2005); //specify a date2

$differenza = ($data2 - $data1 ) / 86400;

echo " The Different $data2 - data1 = $differenza";
?>

[/code]


mysql link for date diffrence ok.

[a href=\"http://www.mysqlfreaks.com/statements/56.php\" target=\"_blank\"]http://www.mysqlfreaks.com/statements/56.php[/a]
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.