`
bee1314
  • 浏览: 163896 次
  • 性别: Icon_minigender_1
  • 来自: 安徽
社区版块
存档分类
最新评论

MySQL yearweek的用法

    博客分类:
  • DB
 
阅读更多

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
分享到:
评论
1 楼 shenzhongji 2012-03-06  
谢了

相关推荐

    mysql_yearweek:用于获取与 MySQL 函数等效的 yearweek 值的 Ruby gem

    安装 $ 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

    c#获取ISO YearWeek

    mysql的日期和时间函数

     如果你更希望能得到恰当的年-周值,那么你应该使用参数 2 或 3 做为可选参数,或者使用函数 YEARWEEK() : mysql> SELECT YEARWEEK(’2000-01-01’); -> 199952 mysql> SELECT MID(YEARWEEK(’2000-01...

    MySQL根据时间范围查询

    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查询当天,查询本周,查询本月的数据实例(字段是时间戳)

    php、mysql查询当天,查询本周,查询本月的数据实例(字段是时间戳) //其中 video 是表名; //createtime 是字段; // //数据库time字段为时间戳 // //查询当天: $start = date('Y-m-d 00:00:00'...SELECT yearweek( '20

    MySQL查询本周、上周、本月、上个月份数据的sql代码

    查询当前这周的数据 SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,’%Y-%m-%d’)) = YEARWEEK(now()); 查询上周的数据 SELECT name,submittime FROM enterprise WHERE YEARWEEK...

    105s print label set

    使用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_...

Global site tag (gtag.js) - Google Analytics