DATEDIF - Date Difference

  • Last update:October 11, 2025
  • Extracted Data

    Overview

    Syntax

    DATEDIF(Start_date,End_date,Unit)

    Returns the number of days, months, or years between two specified dates.

    Parameter 1

    Start_date

    Represents the initial date of the specified period. Only text and date types are supported.

    The Start_date parameter can be serial numbers in the 1900 date system. For example, the serial number 35796 represents January 1,1998.

    Parameter 2

    End_date

    Represents the end date of the specified period. Only text and date types are supported.

    The End_date parameter can be serial numbers in the 1900 date system. For example, the serial number 35796 represents January 1,1998.

    Parameter 3

    Unit

    Represents the type of information returned by the function.

    If Unit is set to Y or y, the function returns the year difference.

    If Unit is set to M or m, the function returns the month difference.

    If Unit is set to D or d, the function returns the day difference.

    If Unit is set to MD or md, the function returns the day difference (ignoring the year and month).

    If Unit is set to YM or ym, the function returns the month difference (ignoring the year and day).

    If Unit is set to YD or yd, the function returns the day difference (ignoring the year).

    Notes

    • The function supports three parameters, with the first two being of the date or text type and the third being of the text type.

    • The third parameter supports Y, M, D, MD, YM, and YD, and is case-insensitive.

    • The function returns the difference between End_date and Start_date. If the difference is negative, it returns the negative value.

    • The NOW function will be used if parameter 1 or parameter 2 is empty in the actual calculation.

    • The field types of parameter 1 and parameter 2 should be the same. They can only be both text fields, or date fields for calculation.

    Example

    1. For example, you want to calculate the month difference between Contract Signing Time and Registration Time. Click Formula Column and enter DATEDIF(Registration Time,Contract Signing Time, "M"), as shown in the following figure.

    Note: The fields in the formula need to be selected from fields on the left. Otherwise, the formula will be invalid.

    2. The result is the month difference between Contract Signing Time and Registration Time. Positive numbers are displayed as positive, and negative numbers are displayed as negative, as shown in the following figure.

    The following table shows more examples.

    Formula

    Result

    Remarks

    DATEDIF("2001/2/28","2004/3/20","Y")

    3

    The year difference between 2001 and  2004

    DATEDIF("2001/2/28","2004/3/20","M")

    37

    The month difference between 2004-03  and 2001-02

    DATEDIF("2001/2/28","2004/3/20","D")

    1116

    The day difference between 2001-02-28  and 2004-03-20

    DATEDIF("2001/2/28","2004/3/20","md")

    -8

    The day difference between the 20th and the 28th, ignoring the month and year.

    DATEDIF("2001/1/28","2004/3/20","YM")

    2

    The month difference between 2001-01-28 and 2004-03-20, ignoring the day and year

    DATEDIF("2001/2/28","2004/3/20","yd")

    21

    The month difference between 2001-02-28 and 2004-03-20, ignoring the year

    DATEDIF(35796,35800,"MD")

    4

    The day difference between 1998-01-01, and 1998-01-05, ignoring the year and month

    Real-Time Data

    Overview

    Syntax

    DATEDIF(Start_date,End_date,Unit)

    Returns the number of days, months, or years between two specified dates.

    Returns the difference between End_date and Start_date and returns the negative value if the difference is negative.

    Parameter   1

    Start_date

    Represents the initial date of the specified period. Only text and date types are supported.

    Parameter   2

    End_date

    Represents the end date of the specified period. Only text and date types are supported.

    Parameter   3

    Unit

    Represents the type of information returned by the function.

    If Unit is set to Y or y, the function returns the year difference.

    If Unit is set to M or m, the function returns the month difference.

    If Unit is set to D or d, the function returns the day difference.

    If Unit is set to MD or md, the function returns the day difference (ignoring the year and month).

    If Unit is set to YM or ym, the function returns the month difference (ignoring the year and day).

    If Unit is set to YD or yd, the function returns the day difference (ignoring the year).

    Notes

    • The function supports three parameters, with the first two being of the date or text type and the third being of the text type.

    Example

    Formula
    Result

    Remarks

    DATEDIF("2001-02-28","2004-03-20","Y")

    3

    The year difference between 2001 and 2004

    DATEDIF("2001-02-28","2004-03-20","M")

    37

    The month difference between 2004-03 and 2001-02

    DATEDIF("2001-02-28","2004-03-20","D")

    1116

    The day difference between 2001-02-28 and 2004-03-20

    DATEDIF("2001-02-28","2004-03-20","md")

    -8

    The day difference between the 20th and the 28th, ignoring the month and year

    DATEDIF("2001-01-28","2004-03-20","YM")

    2

    The month difference between 2001-01-28 and 2004-03-20, ignoring the day and year

    DATEDIF("2001-02-28","2004-03-20","yd")

    21

    The day difference between 2001-02-28 and 2004-03-20, ignoring the year and month

    附件列表


    主题: System Management
    Previous
    Next
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy