YouTip LogoYouTip

Vb Func Dateadd

# VBScript DateAdd Function * * Complete VBScript Reference Manual](#) * * * The DateAdd function returns a date to which a specified time interval has been added. ### Syntax DateAdd(interval,number,date) | Parameter | Description | | :--- | :--- | | interval | Required. The time interval you want to add. Can be one of the following values: * yyyy - Year * q - Quarter * m - Month * y - Day of the year * d - Day * w - Day of the week * ww - Week of the year * h - Hour * n - Minute * s - Second | | number | Required. The number of time intervals you want to add. Use a positive value for future dates and a negative value for past dates. | | date | Required. A variable or literal representing the date to which the interval will be added. | ## Examples ## Example 1 How to use the parameters: document.write(DateAdd("yyyy",1,"31-Jan-10") & "
") document.write(DateAdd("q",1,"31-Jan-10") & "
") document.write(DateAdd("m",1,"31-Jan-10") & "
") document.write(DateAdd("y",1,"31-Jan-10") & "
") document.write(DateAdd("d",1,"31-Jan-10") & "
") document.write(DateAdd("w",1,"31-Jan-10") & "
") document.write(DateAdd("ww",1,"31-Jan-10") & "
") document.write(DateAdd("h",1,"31-Jan-10 08:50:00") & "
") document.write(DateAdd("n",1,"31-Jan-10 08:50:00") & "
") document.write(DateAdd("s",1,"31-Jan-10 08:50:00") & "
") The output of the above example: 1/31/2011 4/30/2010 2/28/2010 2/1/2010 2/1/2010 2/1/2010 2/7/2010 1/31/2010 9:50:00 AM 1/31/2010 8:51:00 AM 1/31/2010 8:50:01 AM [Try it Β»](#) ## Example 2 Subtract one month from January 31, 2001: document.write(DateAdd("m",-1,"31-Jan-10")) The output of the above example: 12/31/2009 [Try it Β»](#) ## Example 3 Add one day from now: document.write(DateAdd("d",1,Now())) The output of the above example: document.write(DateAdd("d",1,Now())) [Try it Β»](#) * * Complete VBScript Reference Manual](#)
← Func TimevalueVb Func Date β†’