ASA SQL Reference
SQL Functions
Alphabetical list of functions
Given two timestamps, this function returns the integer number of seconds between them. It is recommended that you use the DATEDIFF function [Date and time] instead for this purpose.
Given a single date, this function returns the number of seconds since 0000-02-29 00:00:00.
Given one date and an integer, it adds the integer number of seconds to the specified timestamp. It is recommended that you use the DATEADD function [Date and time] instead for this purpose.
Syntax 1 returns a bigint. Syntax 2 returns a timestamp.
SECONDS ( [ datetime-expression, ] datetime-expression )
SECONDS ( datetime-expression, integer-expression )
datetime-expression A date and time.
integer-expression The number of seconds to be added to the datetime-expression. If integer-expression is negative, the appropriate number of minutes is subtracted from the datetime value. If you supply an integer expression, the datetime-expression must be explicitly cast as a datetime data type.
For information on casting data types, see CAST function [Data type conversion].
SQL/92 Vendor extension.
SQL/99 Vendor extension.
Sybase Not supported by Adaptive Server Enterprise.
The following statements return the value 14 400, signifying that the second timestamp is 14 400 seconds after the first.
SELECT SECONDS( '1999-07-13 06:07:12', '1999-07-13 10:07:12' ) SELECT DATEDIFF( second, '1999-07-13 06:07:12', '1999-07-13 10:07:12' )
The following statement returns the value 63 062 431 632.
SELECT SECONDS( '1998-07-13 06:07:12' )
The following statements return the datetime 1999-05-12 21:05:12.0.
SELECT SECONDS( CAST( '1999-05-12 21:05:07' AS TIMESTAMP ), 5) SELECT DATEADD( second, '1999-05-12 21:05:07' )