VistaDB 6
VistaDB / Developer's Guide / SQL Reference / Functions / Date and Time Functions / DATEADD
In This Topic
    DATEADD
    In This Topic
    DATEADD( datepart, number, date )

    Returns a new datetime based on adding to the date passed to the function.

    The following are valid datepart parameters:

    Datepart Abbreviations
    year yy, yyyy
    quarter qq, q
    month mm, m
    dayofyear dy, y
    day dd, d
    week wk, ww
    weekday dw, w
    hour hh
    minute mi, n
    second ss, s
    millisecond ms

    SQL Server Difference

    SQL Server will actually accept the parameters out of order when they are passed from other functions. VistaDB does not support this behavior of SQL Server.

    You also cannot pass 0 as a value for a DATETIME. .Net does not cast a 0 to the minimum date range available.


    Remarks

    Note that the adding of things like month to another month is smart enough to take into account the number of days in a month.

    SELECT DATEADD(month, 1, '08/30/2007') SELECT DATEADD(month, 1, '08/31/2007')

    Both of these will return: 9/30/2007 12:00:00 AM (The end of September).


    Example

    Output:  1/1/2001 12:00:00 AM
    
    
    Output:  1/1/2001 12:00:00 AM
    
    
    Output:  7/15/2007 12:00:00 AM
    
    SELECT DATEADD(quarter, 1, '04/15/2007')
    SELECT DATEADD(yy, 1, '01/1/2000')
    SELECT DATEADD(year, 1, '01/1/2000')
    See Also