A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  special characters  sybase-tech-blog


Category: ASE: Functions: Date and Time Functions

dateadd()

The Date & Time Function dateadd() returns the current date plus or minus a given time value. The time value can be given as any amount of years, quarters, hours or fragments of dates.

Syntax of the Datatype Conversion Function dateadd()

    dateadd( date_part, integer, date expression )
    

Parameters of the Datatype Conversion Function dateadd()

date_part
The parameter "date_part" is a placeholder for the shortcut of a date part.)

integer
The parameter "integer" is a placeholder for a numeric value.

date expression
The parameter "date expression" is a placeholder for a date which can be provided in the format of a datetime, smalldatetime, date (starting with ASE® Version 15.0), time (starting with ASE® Version 15.0) datatype, or as a Character String in a date format.

Example for the Datatype Conversion Function dateadd()

    declare @a datetime
select @a = "Apr 12, 9999"
select dateadd(dd, 1, @a)
go
-----
Apr 13 9999

Adds one day to the given date.

    select dateadd(mi, -5, convert(time, "14:20:00"))
go
-----
2:15PM

Subtracts 5 minutes from the given time.

See also:

ASE T-SQL - Aggregate Functions,
Date and Time Functions,
datediff(),
datename(),
datepart(),
date_part,
day(),
getdate(),
month(),
style numbers,
year().