LoginSignup
0
1

More than 5 years have passed since last update.

MySQL 日付間連 小技

Last updated at Posted at 2013-12-12
  • 月の何日

    dayofmonth(日付)

  • 年の月

    month(日付)

  • 月の初日

    date_sub(日付, interval dayofmonth(日付) -1 day)

  • 月の何週(週初めが日曜の場合)

    week(日付,0) - week(date_sub(日付, interval dayofmonth(日付) -1 day),0) + 1

    ※week関数の第二引数を変えれば、月曜始まりとかにもできる。
    引数の取り得る値は↓
    http://dev.mysql.com/doc/refman/5.1/ja/date-and-time-functions.html

  • 1週間後の日付

    date(日付 + interval 7 day)

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1