Afficher un message
Vieux 04/01/2008, 18h24   #2
Taliesin Nuin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: MySQL problem: date calculation

plenty900@yahoo.com wrote:
> Hi folks,
>
> I'm having a problem with MySQL. I have a table,
> one of whose columns is called `date`, which is a timestamp.
> I need to SELECT all the rows whose timestamps are
> less than 7 days old. To my surprise, all of the examples
> of using DATEDIFF from the MySQL online reference are failing.
>
> For instance, this does not work:
>
> SELECT * FROM mytable WHERE 7 > DATEDIFF(`date`,CURDATE());
>
> Nor does this:
>
> SELECT * FROM mytable WHERE 7 > DATEDIFF(`date`, NOW());
>
> Any ideas?
> Incidentally I'm accessing the db through php_admin,
> and I am not sure how to get the MySQL version number
> but it is not displayed anywhere.
>
> Thanks.


Don't you want the parameters the other way around? I.e.:
DATEDIFF(NOW(),date_val);

You can find the server version of MySQL in PHPMyadmin on the root page
just under the host name called Server Version. (The client version is
across from it on the right).
  Réponse avec citation
 
Page generated in 0,05302 seconds with 9 queries