|
datediff()
The
Date & Time Function
datediff()
returns the difference between two date values.
Syntax of the Datatype Conversion Function datediff()
datediff( date_part, date expression 1, date expression 2 )
The parameter of the Datatype Conversion Function datediff()
date_part
The parameter "date_part" is a placeholder for the abbreviation of a part of a date value. (See also:
date parts.)
date expression 1 and 2
The parameter "date expression" is a placeholder for a date value which can be of any of these
datatypes:
datetime,
smalldatetime,
date (starting with
ASE®
version 15.0),
time (starting with ASE® version 15.0)
or as
character string
in a date format.
Example for the Datatype Conversion Function datediff()
declare @a time
declare @b time
select @a = "20:43:22"
select @b = "11:43:22"
select datediff(hh, @a, @b)
go
-----
-9
Returns the difference of time between @b and @a.
See also:
ASE T-SQL - Aggregate Functions, Date and Time Functions, dateadd(), datename(), datepart(), date_part, day(), getdate(), month(), style numbers, year().
|