Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the time and date functions in Mysql

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

What are the time and date functions in Mysql? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

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): return date data is what day of the week

(1 = Sunday, 2 = Monday. 7 = Saturday, ODBC standard) select dayofweek ('2018-02-13'); / / 3

4.weekday (date): return date data is what day of the week

(0 = Sunday, 1 = Monday... 6 = Saturday, ODBC standard) select WEEKDAY ('1997-10-04 22 2315 00'); / / 5

5.dayofmonth (date): returns the day of the month on which the date is (range 1-31)

Select dayofmonth ('2018-04-21') / / 21

6.dayofyear (date): returns the day of the year (range 1-366) for date

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 date (English name is returned)

Select dayname ('1998-02-05'); / / Thursday

9.monthname (date): how many months does it take to return date?

Select monthname ('2018-02-01') / / February

10.quarter (date): returns the quarter of the year when date is returned

Select quarter ('2018-04-21') / / 2

11.week (date,first): returns date the week ordinal of the year

(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'); / / 7select week ('2018-02-20); / / 7select week (' 2018-02-20); / 8

12.year (date): returns the year in date (range 1000-9999)

Select year ('98-02-03'); / 1998 this is the answer to the question about what time and date functions are available in Mysql. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report