MySQL 的 YEARWEEK 是获取年份和周数的一个函数,函数形式为 YEARWEEK(
date
[,mode
])
例如 2010-3-14 ,礼拜天
SELECT YEARWEEK('2010-3-14') 返回 11
SELECT YEARWEEK('2010-3-14',1) 返回 10
其中第二个参数是 mode ,具体指的意思如下:
Mode | First day of week | Range | Week 1 is the first week … |
0 | Sunday | 0-53 | with a Sunday in this year |
1 | Monday | 0-53 | with more than 3 days this year |
2 | Sunday | 1-53 | with a Sunday in this year |
3 | Monday | 1-53 | with more than 3 days this year |
4 | Sunday | 0-53 | with more than 3 days this year |
5 | Monday | 0-53 | with a Monday in this year |
6 | Sunday | 1-53 | with more than 3 days this year |
7 | Monday | 1-53 | with a Monday in this year |
相关推荐
安装 $ gem install mysql_yearweek示例用法 > require mysql_yearweek=> true> MySQLYearweek.yearweek(Date.new(2013, 07, 25))=> "201330"> MySQLYearweek.yearweek(Date.new(2013, 07, 25), 2)=> "201329"限制这...
c#获取ISO YearWeek
如果你更希望能得到恰当的年-周值,那么你应该使用参数 2 或 3 做为可选参数,或者使用函数 YEARWEEK() : mysql> SELECT YEARWEEK(’2000-01-01’); -> 199952 mysql> SELECT MID(YEARWEEK(’2000-01...
MySQL根据时间范围查询 1. 查询今天 SELECT * FROM 表名 WHERE TO_DAYS(时间字段) = TO_DAYS(NOW()); 2. 查询本周 SELECT * FROM 表名 WHERE YEARWEEK(DATE_FORMAT(时间字段,'%Y-%m-%d')) = YEARWEEK(NOW()); 3. ...
php、mysql查询当天,查询本周,查询本月的数据实例(字段是时间戳) //其中 video 是表名; //createtime 是字段; // //数据库time字段为时间戳 // //查询当天: $start = date('Y-m-d 00:00:00'...SELECT yearweek( '20
查询当前这周的数据 SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,’%Y-%m-%d’)) = YEARWEEK(now()); 查询上周的数据 SELECT name,submittime FROM enterprise WHERE YEARWEEK...
使用vb控制105s打印机指令打印标签,Private Sub Print_Test_SN(Model_Name As String, WeekDate As Date, SN As Long) Dim filehandle As Integer Dim ModelName As String Dim yearweek As String Dim str_...