Jump to content


Photo

DATEDIFF Question


  • Please log in to reply
1 reply to this topic

#1 WendyLady

WendyLady
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 12 June 2006 - 10:55 PM

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!

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 June 2006 - 07:11 AM


<? 
$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";
?> 



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]
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users