This article mainly summarizes some commonly used MySQL time and date and conversion functions in practical applications 1.now(): Returns the current date and time select now(); //2018-04-21 09:19:21 2.curdate() : Returns the current date select curdate(); //2018-04-21 3. dayofweek(data) : Returns the day of the week of the date data (1 = Sunday, 2 = Monday...7 = Saturday, ODBC standard) select dayofweek('2018-02-13'); // 3 4.weekday(date) : Returns the day of the week of the date data (0 = Sunday, 1 = Monday...6 = Saturday, ODBC standard) select WEEKDAY('1997-10-04 22:23:00'); //5 5.dayofmonth(date): Returns the day of the month that date is (range 1-31) select dayofmonth('2018-04-21'); //twenty one 6.dayofyear(date) : Returns the day of the year that date is (range 1-366) select dayofyear('2018-01-01'); //1 7.month(date): Returns the month value in date select month('2018-04-21'); //4 8.dayname(date): returns the day of the week (returns the English name) select dayname('1998-02-05'); //Thursday 9.monthname(date): Returns the month of date (in English) select monthname('2018-02-01') //February 10.quarter(date): Returns the quarter of the year that date is select quarter('2018-04-21'); //2 11.week(date,first): Returns the first week of the year that date is (Parameter first: 0 means Sunday is the beginning of the week, 1 means Monday is the beginning of the week, default is 0) select week('2018-02-20'); // 7 select week('2018-02-20',0); //7 select week('2018-02-20',1); //8 12.year(date): Returns the year in date (range 1000-9999) select year('98-02-03'); //1998 Summarize The above is a summary of the commonly used time, date and conversion functions in MySQL. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Vue implements pull-down to load more
>>: Solve the problem of using linuxdeployqt to package Qt programs in Ubuntu
In summary: 1. Consider performance when designin...
Table of contents MutationObserver API Features I...
Table of contents Docker container data volume Us...
Preface Workbench is installed on one computer, a...
1. Basic Concepts 1. Sitemesh is a page decoratio...
I recently deployed MySQL 5.6 and found that by d...
Sometimes when requesting certain interfaces, you...
Table of contents MAH 1. Introduction to MAH Arch...
ab command principle Apache's ab command simu...
1. Add the viewport tag to the HTML header. At th...
The principle of uploading pictures on the front ...
Table of contents 1. Joint index description 2. C...
Preface: When designing a table in MySQL, MySQL o...
Good database specifications help reduce the comp...