MySQL DATEDIFF () syntax

Source: Internet
Author: User
Tags mysql functions

The following describes the MySQL DATEDIFF () function, which is used to return the number of days between two dates. It is one of the most common MySQL functions and deserves further research.

Definition and usage
The MySQL DATEDIFF () function returns the number of days between two dates.

Syntax
DATEDIFF (date1, date2)
The date1 and date2 parameters are valid date or date/time expressions.

Note: Only the date part of the value is involved in calculation.
Instance
Example 1
Use the following SELECT statement:

Select datediff ('2014-12-30 ', '2014-12-29') AS DiffDate
Result:

DiffDate
1

Example 2
Use the following SELECT statement:

Select datediff ('2014-12-29 ', '2014-12-30') AS DiffDate
Result:

DiffDate
-1

The preceding section describes the MySQL DATEDIFF () syntax.

MySQL Date and Time Extract function Introduction

MySQL date functions

Provides you with an in-depth understanding of the MYSQL Cast function.

MySQL string processing function concat_ws ()

MySQL string segmentation and concatenation statements

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.