mysql日期操作

mysql 昨天的函数


SELECT DATE_SUB(current_date,INTERVAL 1 DAY);

SELECT DATE_SUB(curdate(), INTERVAL 1 DAY);


mysql> select date_sub(curdate(),interval 1 day);
+------------------------------------+
| date_sub(curdate(),interval 1 day) |
+------------------------------------+
| 2006-06-19                         |
+------------------------------------+
1 row in set (0.09 sec)

mysql> select date_sub('2006-06-04',interval 1 day);
+---------------------------------------+
| date_sub('2006-06-04',interval 1 day) |
+---------------------------------------+
| 2006-06-03                            |
+---------------------------------------+
1 row in set (0.00 sec)

select count(*),date_sub(curdate(),interval 1 day) from player p where date(p.createDate)= date_sub(curdate(),interval 1 day) and date(p.loginDate) >date(p.createDate);

你可能感兴趣的:(mysql)