Function for MySQL to obtain the time and date -- sysdate ()

Source: Internet
Author: User
Tags mysql delete mysql manual

If you want MySQL to obtain the time and date, what kind of function is better? Using the sysdate () function allows MySQL to obtain the time and date. Let's take a look at this function.

MySQL returns the current date + time) function sysdate ():

The sysdate () Date and time function is similar to now (). The difference is that now () is obtained at the execution start time, And sysdate () dynamically obtains the value during function execution. You can see the following example:

Mysql> select now (), sleep (3), now ();

+ --------------------- + ---------- + --------------------- +
| Now () | sleep (3) | now () |
+ --------------------- + ---------- + --------------------- +
| 22:28:21 | 0 | 22:28:21 |
+ --------------------- + ---------- + ------------------- + Mysql> select sysdate (), sleep (3), sysdate ();

+ --------------------- + ---------- + --------------------- +
| Sysdate () | sleep (3) | sysdate () |
+ --------------------- + ---------- + --------------------- +
| 22:28:41 | 0 | 22:28:44 |
+ --------------------- + ---------- + --------------------- +
We can see that although sleep lasts for 3 seconds, the time values of the now () function are the same. The time values obtained by the sysdate () function differ by 3 seconds. In MySQL Manual, sysdate () is described as follows: Return the time at which the function executes.

Sysdate () Date and time functions are rarely used.

Learn more about mysql CONCAT () Functions

MySQL string segmentation and concatenation statements

How to modify the default Character Set of mysql

How does MySQL Delete foreign key definitions?

Four conditions for using the MySQL foreign key

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.