Contents Index MINUTE function [Date and time] MOD function [Numeric]

ASA SQL Reference
  SQL Functions
    Alphabetical list of functions

MINUTES function [Date and time]


Function 

Given two timestamps, this function returns the integer number of minutes 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 minutes since 0000-02-29 00:00:00.

Given one date and an integer, it adds the integer number of minutes to the specified timestamp. Instead, please use the DATEADD function [Date and time].

Syntax 1 returns an integer. Syntax 2 returns a timestamp.

Syntax 1 

MINUTES ( [ datetime-expression, ] datetime-expression )

Syntax 2 

MINUTES ( datetime-expressioninteger-expression )

Parameters 

datetime-expression    A date and time.

integer-expression    The number of minutes 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].

Usage 

Since this function returns an integer, overflow may occur when syntax 1 is used with timestamps greater than or equal to 4083-03-23 02:08:00.

Standards and compatibility 
Example 

The following statements return the value 240, signifying that the second timestamp is 240 seconds after the first. It is recommended that you use the second example (DATEDIFF).

SELECT MINUTES( '1999-07-13 06:07:12',
    '1999-07-13 10:07:12' )
SELECT DATEDIFF( minute,
     '1999-07-13 06:07:12',
     '1999-07-13 10:07:12' )

The following statement returns the value 1 051 040 527.

SELECT MINUTES( '1998-07-13 06:07:12' )

The following statements return the timestamp 1999-05-12 21:10:07.0. It is recommended that you use the second example (DATEADD).

SELECT MINUTES( CAST( '1999-05-12 21:05:07'
AS DATETIME ), 5)
SELECT DATEADD( minute, 5, '1999-05-12 21:05:07' )

Contents Index MINUTE function [Date and time] MOD function [Numeric]