AddDate()

Syntax

Date = AddDate(Date, Type, Value)
Description
Add an amount of time to a date.

Parameters

Date The date value to which the value should be added.
Type The value type. It can be one of the following constants:
  #PB_Date_Year   : Will add 'Value' Years to the date
  #PB_Date_Month  : Will add 'Value' Months to the date
  #PB_Date_Week   : Will add 'Value' Weeks to the date
  #PB_Date_Day    : Will add 'Value' Days to the date
  #PB_Date_Hour   : Will add 'Value' Hours to the date
  #PB_Date_Minute : Will add 'Value' Minutes to the date
  #PB_Date_Second : Will add 'Value' Seconds to the date
Note: when #PB_Date_Month is used, it will automatically account for the fact that the numbers of days per month varies, for example: if a month is added to '31 march 2008' the result will be '30 april 2008', since april does not have 31 days.
Value The value to add to the date. A negative value can be used to subtract a date.

Return value

Returns the new date, -1 otherwise.

Example


  Debug FormatDate("%yyyy/%mm/%dd", AddDate(Date(), #PB_Date_Year, 2)) ; Returns the current date + 2 years

  Debug FormatDate("%mm/%dd/%yyyy", AddDate(Date(), #PB_Date_Year, 2)) ; Returns the current date + 2 years

See Also

Date(), FormatDate()

Supported OS

All

Date Index - Date() ->