O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

DateAdd Function

Class

Microsoft.VisualBasic.DateAndTime

Syntax

DateAdd(interval, number, datevalue)
interval (required; String or DateInterval enum)

A String expression (see the first item in Section ) or a member of the DateInterval enumeration (see the second item in Section ) that specifies the interval of time to add

number (required; Double)

An expression denoting the number of time intervals you want to add (it can be positive or negative)

datevalue (required; Date, or an expression capable of conversion to a date)

Date representing the starting date to which the interval is to be added

Return Value

A past or future Date that reflects the result of the addition

Description

Returns a Date representing the result of adding (or subtracting, if number is negative) a given number of time periods to or from a given date. For instance, you can calculate the date 178 months before today’s date, or the date and time 12,789 minutes from now.

Rules at a Glance

  • interval can be one of the following literal strings:

String

Description

yyyy

Year

q

Quarter

m

Month

y

Day of year

d

Day

w

Weekday

ww

Week

h

Hour

n

Minute

s

Second

  • interval can also be a member of the DateInterval enum:

    Enum DateInterval
       Day
       DayOfYear
       Hour
       Minute
       Month
       Quarter
       Second
       Week
       Weekday
       WeekOfYear
    End Enum
  • If number is positive, the result will be in the future; if number is negative, the result will be in the past. (The meaning of “future” and “past” here is relative to datevalue.)

  • The DateAdd function ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required