Jump to content

Archived

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

WendyLady

DATEDIFF Question

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!

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.