| Start | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Calendar VBA supports 2 calendars : Gregorian (opens new window) and Hijri (opens new window) The The 2 values for the Calendar are:
ExampleThis Sub prints the following ; |
||||||||||||||||||||||||||||||||||||||||||||||
Base functions Retrieve System DateTimeVBA supports 3 built-in functions to retrieve the date and/or time from the system's clock.
Timer FunctionThe Because IsDate()IsDate() tests whether an expression is a valid date or not. Returns a |
||||||||||||||||||||||||||||||||||||||||||||||
| Extraction functions These functions take a
Examples: DatePart() Function
Syntax: interval argument can be :
firstdayofweek is optional. it is a constant that specifies the first day of the week. If not specified, firstweekofyear is optional. it is a constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs. Examples: |
||||||||||||||||||||||||||||||||||||||||||||||
Calculation functions DateDiff()
Syntax
Examples DateAdd()
Syntax
Examples : |
||||||||||||||||||||||||||||||||||||||||||||||
Conversion and Creation CDate()
Note that VBA also has a loosely typed DateSerial()
Syntax: With year, month and day arguments being valid Integers (Year from 100 to 9999, Month from 1 to 12, Day from 1 to 31). Examples Note that Positive Example However, it is more likely to cause grief when attempting to create a date from unvalidated user input: Negative Example |
Read Article
https://develop.horje.com/learn/1434/reference