Get the App
SLTechnology News&Howtos  ›  Database  › 

What are the time functions in mysql

Shulou Source: shulou.com Published: 2022-05-31 21:20:55 10月05日 Update

Mysql in which time functions, many novices are not very clear, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Get the current date + time (date + time) function: now (), sysdate ()

The differences are as follows:

MySQL gets the current time functions: current_timestamp, current_timestamp (), current_time, current_time (), current_date, current_date ()

As follows:

MySQL date / time conversion to string functions: date_format (date,format), time_format (time,format)

As follows:

Change varchar type to date type in mysql: str_to_date (str, format)

As follows:

MySQL date / day conversion function: to_days (date), from_days (days)

As follows:

MySQL (time, second) conversion function: time_to_sec (time), sec_to_time (seconds)

As follows:

MySQL adds a time interval to the date: date_add ()

As follows:

MySQL subtracts a time interval from the date: date_sub ()

As follows:

MySQL date and time subtraction function: datediff (date1,date2), timediff (time1,time2). Note: the two parameter types of the timediff (time1,time2) function must be the same.

As follows:

MySQL timestamp (timestamp) conversion, increment and subtraction functions: timestamp (date), timestamp (dt,time), timestampadd (unit,interval,datetime_expr), timestampdiff (unit,datetime_expr1,datetime_expr2)

As follows:

The MySQL timestampdiff () function is more powerful than datediff (), and datediff () can only calculate the number of days between two dates (date).

MySQL time zone (timezone) conversion function: convert_tz (dt,from_tz,to_tz)

Time zone conversion can also be achieved through date_add, date_sub, and timestampadd.

As follows:

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Function time date type two days time zone help powerful clear same between content function powerful parameter can pass character string for this Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn Apple Xiaomi Microsoft