EasyManua.ls Logo

Sybase Adaptive Server Anywhere - Page 345

Sybase Adaptive Server Anywhere
1182 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 8 SQL Functions
327
date-expression1 The starting date for the interval. This value is
subtracted from date-expression2 to return the number of date-parts between
the two arguments.
date-expression2 The ending date for the interval. Date-expression1 is
subtracted from this value to return the number of date-parts between the
two arguments.
The following statement returns 1:
SELECT datediff( hour, ’4:00AM’, ’5:50AM’ )
The following statement returns 102:
SELECT datediff( month, ’1987/05/02’, ’1995/11/15’ )
.The following statement returns 0:
SELECT datediff( day, ’00:00’, ’23:59’ )
The following statement returns 4:
SELECT datediff( day, ’1999/07/19 00:00’, ’1999/07/23
23:59’ )
The following statement returns 0:
SELECT datediff( month, ’1999/07/19’, ’1999/07/23’ )
The following statement returns 1:
SELECT datediff( month, ’1999/07/19’, ’1999/08/23’ )
This function calculates the number of date parts between two specified
dates. The result is a signed integer value equal to (date2 - date1), in date
parts.
DATEDIFF results are truncated, not rounded, when the result is not an even
multiple of the date part.
When you use day as the date part, DATEDIFF returns the number of
midnights between the two times specified, including the second date but not
the first.
When you use month as the date part, DATEDIFF returns the number of
first-of-the-months between two dates, including the second date but not the
first.
When you use week as the date part, DATEDIFF returns the number of
Sundays between the two dates, including the second date but not the first.
For the smaller time units there are overflow values:
milliseconds 24 days
seconds 68 years
Examples
Usage

Table of Contents

Related product manuals