Be the first user to complete this post
|
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
- Mandatory
- Type: String expression
- The time interval you want to add
Setting | Description |
Yyyy | Year |
Q | Quarter |
M | Month |
Y | Day of year |
D | Day |
W | Weekday |
Ww | Week |
H | Hour |
N | Minute |
S | Second |
- number
- Mandatory
- Type: Numeric
- The number of intervals you want to add
- date
- Mandatory
- 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
Also Read:
- VBA-Excel: Create Array using Array() Function
- VBA-Excel: Arrays – Two Dimension, Dynamic Array
- VBA-Excel: String Functions – Mid()
- VBA-Excel: Date-Time Functions – CDate()
- VBA-Excel: Select and Activate Cells - Activate