感谢:http://www.111cn.net/database/110/d45124323da8d2d87b80f78319987eda.htm
查看同主题的另一篇博客:http://blog.csdn.net/cleanfield/article/details/41447585
------------------------------------------------------------------------------
本季度的第一天 ,然后你可以把字符串再转换为日期。 方法很多,包括同一个函数的别名(同义词)也很多。比如CURDATE(),CURRENT_DATE(), CURRENT_DATE, NOW 等都可以返回当天
mysql教程> select CURDATE(),ELT(QUARTER(CURDATE()),
-> year(CURDATE())*1000+0101,
-> year(CURDATE())*1000+0401,
-> year(CURDATE())*1000+0701,
-> year(CURDATE())*1000+1001) as firstDayofQ;
+------------+-------------+
| CURDATE() | firstDayofQ |
+------------+-------------+
| 2009-05-19 | 2009401 |
+------------+-------------+
1 row in set (0.00 sec)
mysql>
用mysql语句获取本季度的第一天
本月的第一天,
date(
concat(year(curdate()),'-',month(curdate()),'-','1'))
本周的第一天
curdate()-
WEEKDAY(curdate())
用mysql语句获取本季度的第一天
date(
concat(year(curdate()),'-',
if(quarter(curdate())=1,1,if(quarter(curdate())=2,4,if(quarter(curdate())=3,7,10))
用mysql语句获取本季度的第一天:
优化:
date(
concat(year(curdate()),'-',elt(quarter(curdate()),1,4,7,10),'-',1))
本周的第一天
date_add(date('2009-5-29'),INTERVAL -weekday('2009-5-29') day)
mysql 获取当天发布文件内容sql语句
SELECT * FROM `p8_memberdata` where regdate BETWEEN (UNIX_TIMESTAMP(NOW())-86440) AND NOW()
SELECT * FROM `p8_memberdata` WHERE DATE_FORMAT(FROM_UNIXTIME(regdate),'%Y-%m-%d')= DATE_FORMAT(NOW(),'%Y-%m-%d') order by uid desc