Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Date-Time Functions – DateAdd()

Description:

The DateAdd () function adds the specified time interval to the date and returns a Variant (Date)

Format:

DateAdd(interval,number,date)

Arguments:
  • interval
    • Manda­tory
    • Type: String expression
    • The time interval you want to add
SettingDescription
YyyyYear
QQuarter
MMonth
YDay of year
DDay
WWeekday
WwWeek
HHour
NMinute
SSecond
  •  number
  • Manda­tory
  • Type: Numeric
  • The number of intervals you want to add
  • date
    • Manda­tory
    • Type : Date
    • Date in which the interval will be added

Example:

Function FnDateAdd()

Dim strDate

strDate = CDate("June 24, 2013")    

strNewDate = DateAdd("m", 2, strDate)

MsgBox strNewDate

strNewDate2 = DateAdd("yyyy", -3, strDate)

MsgBox strNewDate2

strDate2 = CDate("June 24, 2013 12:00:00 PM")    

MsgBox DateAdd("h", 2, DateAdd("n", 23, strDate2))

End Function 
AddDate
AddDate



Also Read:

  1. VBA-Excel: Arrays – Multi Dimensional Array
  2. VBA-Excel: Date-Time Functions – DateSerial()
  3. VBA Excel – Looping Through a Range of Cells
  4. VBA-Excel : 3D-Ranges - Working with Multiple WorkSheets At The Simultaneously
  5. VBA-Excel : Strings Functions – Lcase