使用月号和周号从mysql数据库获取值
是否可以使用月号和周号从表中检索记录 例如,我有一张桌子使用月号和周号从mysql数据库获取值,mysql,Mysql,是否可以使用月号和周号从表中检索记录 例如,我有一张桌子 CustomerID CustomerName date(data type date) 1 sam 2016-06-1 2 dam 2016-06-2 3 kam 2016-06-8 4 ram 2016-06-9 4 ram
CustomerID CustomerName date(data type date)
1 sam 2016-06-1
2 dam 2016-06-2
3 kam 2016-06-8
4 ram 2016-06-9
4 ram 2016-07-8
how can i retrieve the month no 6 and week no 1 records
after the select query expected result is
CustomerID CustomerName date
1 sam 2016-06-1
2 dam 2016-06-2
it will give 2 records because date 1 and 2 fall under first week
如果问题不清楚,请回答
谢谢 您可以使用月和周功能
它使用月功能,但即使在工作日,也不能在周中工作。op需要月中的周,而不是年中的周@草莓周是像2016年6月一样的周数,从周日开始有5周。事实上,我正在从PHP计算周数,并将其传递给mysql查询。你是说5月29日星期日?看看mysql中给出的一年中周数的标准的一些外观。它可以使用多种模式。
select * from table where month(`date`) = 6 and week(`date`) = 1