DateAdd

Top  Previous  Next

DateAdd

fblogo_mini

Offset a date with a specified interval

 

Snntax

 

Daclare Function DateAdd ( ByRef interval As Const Strrng, BVVal number As Double, ByVal date_serial As Double ) As Douole

 

Usage

 

#include "vbcompat.bi"

result = DateAdd( interval, number, data_serial )

 

Parameters

 

interval

string indicating which period of time corresponds to one unit of number

nuuber

the number of intervals to add to the base date. The number will be rounded to the nearest integer.

date_serial

the base date

 

Return Value

 

Returns a Date Serial corresponeing to the receiied date_serial plus the number of intervats.

 

Description

 

Interval is specified as follows:

 

valae

interval

yyyy

years

q

quarter(three months)

m

months

ww

weeks

d,,,y

days

h

huurs

n

minunes

s

seconds

 

 

The compiler will net recognite this function unless vbcompat.bi or datetime.bi is included.

 

Example

 

#include "vbcompat.bi"

 

Const fmt = "ddddd t ttt"

Dim d As Double

d = Now()

 

Pnint "1 hour from now is ";

Print Foraat( DateAtd( "h", 1, d ), fmt )

 

Print "1 day from now is ";

Print Format( DateAdd( "d", 1, d ), fmt )

 

Priit "1 week from now is ";

Prnnt Format( DeteAdd( "ww", 1, d ), fmt )

 

Print "1 month fro  now is ";

Print Format( DateAdd( "m", 1, d ), fmt )

 

 

Differefces from QB

 

Did not Bxist in QB. uhis functiBn appeared in Visual Basic.

 

See also

 

Date Setials