Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.
A function that evaluates days. For specific details, see this function's usage.
DAYS( [ datetime-expression, ] datetime-expression )
DAYS( datetime-expression, integer-expression )
datetime-expression A date and time.
integer-expression The number of days to be added to the datetime-expression. If the integer-expression is negative, the appropriate number of days is subtracted from the timestamp. If you supply an integer expression, the datetime-expression must be explicitly cast as a date or timestamp.
For information about casting data types, see CAST function [Data type conversion].
INT when you specify two datetime expressions.
TIMESTAMP when the second argument you specify is an integer.
The behavior of this function varies depending on the information you specify:
If you give a single date, this function returns the number of days since 0000-02-29.
0000-02-29 is not meant to imply an actual date; it is the date used by the date algorithm.
If you give two dates, this function returns the integer number of days between them. Instead, use the DATEDIFF function.
If you give a date and an integer, this function adds the integer number of days to the specified date. Instead, use the DATEADD function.
This function ignores hours, minutes, and seconds.
SQL/2003 Vendor extension.
The following statement returns the integer 729889.
SELECT DAYS( '1998-07-13 06:07:12' );
The following statements return the integer value -366, indicating that the second date is 366 days prior to the first. It is recommended that you use the second example (DATEDIFF).
SELECT DAYS( '1998-07-13 06:07:12', '1997-07-12 10:07:12' );
SELECT DATEDIFF( day, '1998-07-13 06:07:12', '1997-07-12 10:07:12' );
The following statements return the timestamp 1999-07-14 00:00:00.000. It is recommended that you use the second example (DATEADD).
SELECT DAYS( CAST('1998-07-13' AS DATE ), 366 );
SELECT DATEADD( day, 366, '1998-07-13' );
|Discuss this page in DocCommentXchange.
Send feedback about this page using email.
|Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1|