MS Excel: How to use the DATEADD Function (VBA)
The VBA DateAdd function is under the date and time category of Excel’s VBA functions. By using this function we can add or subtract years, months, days, quarters, and even different time intervals like hours, minutes, seconds from a given date. Dealing with date and time in daily calculations for generating reports or making comparisons is a common scenario. In Excel, the use of VBA date and time functions like the DateAdd function makes complex or time-consuming calculations more efficient and faster.
Description
The Microsoft Excel DATEADD function returns a date after which a certain time/date interval has been added.
The DATEADD function is a built-in function in Excel that is categorized as a Date/Time Function. It can be used as a VBA function (VBA) in Excel. As a VBA function, you can use this function in macro code that is entered through the Microsoft Visual Basic Editor.
Syntax
The syntax for the DATEADD function in Microsoft Excel is:
DateAdd ( interval, number, date )
Use of Excel VBA DateAdd Function
interval | number | Date | Formula Expression | Result |
---|---|---|---|---|
y-Year | 2 | 03/01/2022 | Date("yyyy",-2,Range("D2") | 1/3/2022 |
y-Quater | 2 | 03/01/2022 | Date("q",2,Range("D2") | 7/3/2022 |
m-Month | 2 | 03/1/2022 | Date("m",2,Range("D2") | 03/24/2022 |
d-Day | 2 | 03/1/2022 | Date("d",2,Range("D2") | 24/3/2022 |
w-WeekDay | 10 | 03/1/2022 | Date("w",10,Range("D2") | 24/11/2022 |
ww-WeekDay | 10 | 03/1/2022 | Date("ww",10,Range("D2") | 03/15/2022 |
Watching My Video is Below
No comments:
Post a Comment