|< 1 2 3 4 >| | 31 Einträge, 4 Seiten |
1
2
3
4
5
6
7
8
my $sth_prepare = $dbh1->prepare("SELECT datediff(now(),datestamp) AS days_ago, count(datediff(now(),datestamp) ) AS count_days FROM userlog group by 2");
$sth_prepare->execute() or die $DBI::errstr;
print "Content-Type: text/html\n\n";
for ($sth_prepare->fetchrow_array()) {
print $_."\n";
}
SELECT datediff(now(),datestamp) AS days_ago, count(datediff(now(),datestamp) ) AS count_days FROM userlog group by days_ago
QuoteDATEDIFF(expr,expr2)
DATEDIFF() returns the number of days between the start date expr and the end date expr2. expr and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.
mysql> SELECT DATEDIFF('1997-12-31 23:59:59','1997-12-30');
-> 1
mysql> SELECT DATEDIFF('1997-11-30 23:59:59','1997-12-31');
-> -31
DATEDIFF() was added in MySQL 4.1.1.
1
2
mysql> SELECT DATEDIFF('1997-11-30 23:59:59','1997-12-31');
ERROR 1064: You have an error in your SQL syntax near '('1997-11-30 23:59:59','1997-12-31')' at line 1
SELECT count(*) FROM userlog WHERE TO_DAYS(NOW()) - TO_DAYS(datestamp) <= 30 GROUP BY datestamp
|< 1 2 3 4 >| | 31 Einträge, 4 Seiten |