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

How to enter datetime data by mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how mysql input datetime data, I hope you will learn a lot after reading this article, let's discuss it together!

Mysql input date data method: 1, use the function [now ()] input; 2, use the function [current_timestamp ()] input; 3, use the function [, current_timestamp] input; 4, use the function [, localtime ()] input.

The method of entering datetime data by mysql:

Programming examples for getting Date time data:

Mysql > select now (); | now () | | 2008-08-08 22:20:46 |

In addition to the now () function that gets the current date and time, there are the following functions in MySQL:

Current_timestamp ()

, current_timestamp

, localtime ()

, localtime

, localtimestamp-(v4.0.6)

, localtimestamp ()-- (v4.0.6)

These date-time functions are all equivalent to now (). Since the now () function is short and easy to remember, it is recommended that you always use now () instead of the functions listed above.

Extended data:

The type of time-date function (Date Time) of MySql:

1. Function ADDDATE (date,INTERVAL expr type) ADDDATE (expr,days)

Function instructions: when activated by the INTERVAL format of the second parameter, ADDDATE () is synonymous with DATE_ADD (). The related function SUBDATE () is synonymous with DATE_SUB (). For information on the INTERVAL parameter, see the discussion on DATE_ADD ().

2. Function ADDTIME (expr,expr2)

Function instructions: ADDTIME () adds expr2 to expr and returns the result. Expr is a time or time-date expression, while expr2 is a time expression.

3. Function CONVERT_TZ (dt,from_tz,to_tz)

Function instructions: CONVERT_TZ () transfers the time date value dt from the time zone given by from_tz to the time zone given by to_tz, and then returns the result value. For a detailed discussion of the time zone that may be specified, this function returns NULL if the argument is invalid

After reading this article, I believe you have a certain understanding of how mysql enters datetime data. Want to know more about it. Welcome to follow the industry information channel. Thank you for your reading!

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