Summary of MySQL date and time functions

Source: Internet
Author: User
MySQL date and time functions are commonly summarized. if you need a friend, you can refer to the following to obtain the current date + time (date + time) 1.1 Function: now ()

    Related functions: current_timestamp (), localtime (), localtimestamp ()

    Example:



    2. get the current date)

    Function: curdate ()

    Related functions: current_date (), current_date

    Example:



    3. get the current time (time)

    Function: curtime ()

    Related functions: current_time (), current_time

    Example


    4. MySQL dayof...

    Functions: dayofweek (), dayofmonth (), and dayofyear () return the date parameters in the positions of one week, one month, and one year.

    Example

    Set @ dt = '2017-08-08 ';

    Select dayofweek (@ dt); -- 6

    Select dayofmonth (@ dt); -- 8

    Select dayofyear (@ dt); -- 221

    The date '2017-08-08 'is the first day of the week (1 = Sunday, 2 = Monday ,..., 7 = Saturday)

    January days in 8th; 221st days in a year

    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.