Obtain the first day/last day of week, month, and quarter in MySQL.

Source: Internet
Author: User
[Go to] obtain the first day of the current week, month, and quarter in MySQL on the last day. The last day of the current week, month, and quarter in MySQL is taken from: hideto. javaeye. comblog255816 the first day of the current week: selectdate_sub (curdate (), INTERVALWEEKDAY (curdate () + 1DAY) Current week

[Go to] obtain the first day of the current week, month, and quarter in MySQL/the last day of the current week, month, and quarter in MySQL. Part 1: date_sub (curdate (), interval weekday (curdate () + 1 DAY) Current week

[Go to] obtain the first day/last day of the current week, month, and quarter in MySQL
Obtain the first day/last day of the current week, month, and quarter in MySQL: http://hideto.javaeye.com/blog/255816 The first DAY of the current week: select date_sub (curdate (), interval weekday (curdate () + 1 DAY) the last DAY of the current week: select date_sub (curdate (), interval weekday (curdate ()-5 DAY) the first DAY of the previous week: select date_sub (curdate (), interval weekday (curdate () + 8 DAY) the last DAY of the previous week: select date_sub (curdate (), interval weekday (curdate () + 2 DAY) First DAY of the first two week: select date_sub (curdate (), interval weekday (curdate ()) + 15 days) the last DAY of the first two week: select date_sub (curdate (), interval weekday (curdate () + 9 DAY) the first DAY of the current month: SELECT concat (date_format (LAST_DAY (now (), '% Y-% m-'), '01') Last day of the current month: SELECT LAST_DAY (now ()) first day of the previous month: SELECT concat (date_format (LAST_DAY (now ()-interval 1 month), '% Y-% m-'), '01 ′) last day of the previous month: First day of the first two months of SELECT LAST_DAY (now ()-interval 1 month): SELECT concat (date_format (LAST_DAY (now ()-interval 2 month ), '% Y-% m-'), '01') the last day of the first two months: SELECT LAST_DAY (now ()-interval 2 month) the first day of the current quarter: select concat (date_format (LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-3 month ), '% Y-% m-'), '01') Last day of the current quarter: select LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-1 month) the first day of the previous quarter: select concat (date_format (LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-6 month), '% Y-% m-'), '01') the last day of the previous quarter: select LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-4 month) the first two quarter's first day: select concat (date_format (LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-9 month ), '% Y-% m-'), '01') Last day of the first two quarter: select LAST_DAY (MAKEDATE (EXTRACT (year from curdate (), 1) + interval QUARTER (CURDATE () * 3-7 month)

?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.