MySQL single get system time, year, month, day

Source: Internet
Author: User

MySQL database gets system time, year, month, day single fetch

Get current system date Time: Select Sysdate () as System datetime;

Get current system Month Day: Select Current_date as Month day;

Gets the current system year: Select Year (current_date) as;

Gets the current system month: Select Month (current_date) as month;

Get current system date: Select Day (current_date) as date;

Get current system time: Select Time (Sysdate ()) as system times;

Get current system hour: Select HOUR (Sysdate ()) as System hour;

Get current system minutes: Select MINUTE (Sysdate ()) as system minutes;

Get current system seconds: Select SECOND (Sysdate ()) as system seconds;

Gets the current system millisecond: Select Microsecond (Sysdate ()) as system seconds;

MySQL database gets system time, year, month, day single fetch

Get system time in MySQL database, year, month, day

Select curdate(); --Get the current date

< Span class= "Sql1-space" >select last_day ( curdate ()); --Gets the last day of the month.

< Span class= "sql1-function" >select DATE_ADD (curdate (), Interval -day (curdate ()) + 1day -Get the first day of the month

select date_add ( curdate ()-day (curdate ()) + 1,interval 1 month --Get the first day of next month

Select DATEDIFF(Date_add(Curdate()-Day(Curdate())+1,Interval 1 month ), date_add (curdate (), interval -day (curdate () +1 Day from dual; Span class= "sql1-comment" > --Get the number of days in the current month

Select Curtime ()  ---get current system time

Select Sysdate (), Current_timestamp (), now (), localtime (), L Ocaltimestamp ()  ---- Get current system date + time

MySQL single get system time, year, month, day

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.