Main > Knowledge Base > Developer resources > Development recommendations > Query language > Specifics of DATEDIFF function of the query language > Developer resources > Development recommendations > Query language > Specifics of DATEDIFF function of the query language > Developer resources > Development recommendations > Query language > Specifics of DATEDIFF function of the query language

Specifics of DATEDIFF function of the query language

The DATEDIFF function of the query language is intended to get the difference between two dates in a specified measurement unit. The syntax of the function is as follows:

DATEDIFF(<Expression>, <Expression>, Second | Minute | Hour | Day | Month | Quarter | Year)

The first parameter value is subtracted from the second parameter value.

The third parameter defines the measurement unit for the function result. You can use the following values in the third parameter: Second, Minute, Hour, Day, Month, Quarter, and Year. When calculating the result, the function ignores the measurement units that are smaller than the one specified in this parameter.

For example, if you specify Hour in the third parameter, minutes and seconds in the first two parameters are ignored. If you specify Month in the third parameter, then days, hours, minutes, and seconds are ignored.

The following table provides examples of the function return values:

Function Result
DATEDIFF(DATETIME(2002, 12, 31, 10, 20, 34), DATETIME(2003, 01, 01, 9, 18, 06), SECOND)

82 652

DATEDIFF(DATETIME(2002, 12, 31, 10, 20, 34), DATETIME(2003, 01, 01, 9, 18, 06), MINUTE)

1 378

DATEDIFF(DATETIME(2002, 12, 31, 10, 20, 34), DATETIME(2003, 01, 01, 9, 18, 06), HOUR)

23

DATEDIFF(DATETIME(2002, 12, 31, 10, 20, 34), DATETIME(2003, 01, 01, 9, 18, 06), DAY)

1

DATEDIFF(DATETIME(2002, 12, 31, 10, 20, 34), DATETIME(2003, 01, 01, 9, 18, 06), MONTH)

1

DATEDIFF(DATETIME(2002, 12, 31, 10, 20, 34), DATETIME(2003, 01, 01, 9, 18, 06), QUARTER)

1

DATEDIFF(DATETIME(2002, 12, 31, 10, 20, 34), DATETIME(2003, 01, 01, 9, 18, 06), YEAR)

1

DATEDIFF(DATETIME(2002, 01, 01, 0, 0, 0), DATETIME(2002, 12, 31, 23, 59, 59), SECOND)

31 535 999

DATEDIFF(DATETIME(2002, 01, 01, 0, 0, 0), DATETIME(2002, 12, 31, 23, 59, 59), MINUTE)

525 599

DATEDIFF(DATETIME(2002, 01, 01, 0, 0, 0), DATETIME(2002, 12, 31, 23, 59, 59), HOUR)

8 759

DATEDIFF(DATETIME(2002, 01, 01, 0, 0, 0), DATETIME(2002, 12, 31, 23, 59, 59), DAY)

364

DATEDIFF(DATETIME(2002, 01, 01, 0, 0, 0), DATETIME(2002, 12, 31, 23, 59, 59), MONTH)

11

DATEDIFF(DATETIME(2002, 01, 01, 0, 0, 0), DATETIME(2002, 12, 31, 23, 59, 59), QUARTER)

3

DATEDIFF(DATETIME(2002, 01, 01, 0, 0, 0), DATETIME(2002, 12, 31, 23, 59, 59), YEAR)

0

 Next page: Specifics of executing SUBSTRING() function of the query language





© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.