DateAdd

Public Function DateAdd(ByVal Interval As String, ByVal Number As Long, ByVal DateTime As Date) As Date

Adds a number of time intervals to a date.

Dim lDateTime As Date = #2000-01-01#
SendDebug DateAdd("yyyy", 1, lDateTime) 'Prints '#2001-01-01#'
SendDebug DateAdd("q", 1, lDateTime) 'Prints '#2000-04-01#'
SendDebug DateAdd("m", 1, lDateTime) 'Prints '#2000-02-01#'
SendDebug DateAdd("y", 1, lDateTime) 'Prints '#2000-01-02#'
SendDebug DateAdd("d", 1, lDateTime) 'Prints '#2000-01-02#'
SendDebug DateAdd("w", 1, lDateTime) 'Prints '#2000-01-02#'
SendDebug DateAdd("ww", 1, lDateTime) 'Prints '#2000-08-01#'
SendDebug DateAdd("h", 1, lDateTime) 'Prints '#2000-01-01 01:00:00#'
SendDebug DateAdd("n", 1, lDateTime) 'Prints '#2000-01-01 00:01:00#'
SendDebug DateAdd("s", 1, lDateTime) 'Prints '#2000-01-01 00:00:01#'

   'You can also add days using numbers. 1 day equals 1, halve a day (12 hours) 0.5, 1 hour = 1.0/24, 1 second = 1.0/86400 etc.
SendDebug lDateTime + 1 'Prints '#2000-01-02#'
SendDebug lDateTime + 3.75 'Prints '#2000-01-04 18:00:00#'

See also: