Jump to content


Photo

Today added


  • Please log in to reply
3 replies to this topic

#1 domic

domic
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 03 May 2006 - 08:11 PM

Hy,

In my mysql database is row date, and it is in format 00-00-00 00:00:00

And I want, in php file, show how many items is added today...

So, $query="SELECT * FROM table WHERE date="TODAY"";

how to put this correctly?

#2 todd3834

todd3834
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 03 May 2006 - 08:35 PM

[!--quoteo(post=371044:date=May 3 2006, 01:11 PM:name=domic)--][div class=\'quotetop\']QUOTE(domic @ May 3 2006, 01:11 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
how to put this correctly?
[/quote]

$query="SELECT * FROM table WHERE date=NOW();";

As long as your dates use the format 00-00-00 00:00:00 then you use the NOW() function in MySQL

instead of TODAY use NOW()

The two functions that may be helpful to anyone reading this would be NOW() and CURDATE()

NOW() will return the date/time in the format "00-00-00 00:00:00"

CURDATE() will return the date in the format "0000-00-00"

#3 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 03 May 2006 - 08:39 PM

But it's always easier if your dates were stored in the form of unix timestamps...that way, queries are easy as pie...and you can do any date formatting you want, after you pull the data from the db. :-)
PHP Ninja

#4 domic

domic
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 03 May 2006 - 08:45 PM

Ok, but I don't need "now", i only want today, so from that date i need this 00-00-0000 00:00:00

Because, if I use this variable: $num=mysql_numrows($result); it will always be 0.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users