Tutorial by Examples

VBA supports 2 calendars : Gregorian and Hijri The Calendar property is used to modify or display the current calendar. The 2 values for the Calendar are: ValueConstantDescription0vbCalGregGregorian calendar (default)1vbCalHijriHijri calendar Example Sub CalendarExample() 'Cache the curren...
Retrieve System DateTime VBA supports 3 built-in functions to retrieve the date and/or time from the system's clock. FunctionReturn TypeReturn ValueNowDateReturns the current date and timeDateDateReturns the date portion of the current date and timeTimeDateReturns the time portion of the current d...
These functions take a Variant that can be cast to a Date as a parameter and return an Integer representing a portion of a date or time. If the parameter can not be cast to a Date, it will result in a run-time error 13: Type mismatch. FunctionDescriptionReturned valueYear()Returns the year portion ...
DateDiff() DateDiff() returns a Long representing the number of time intervals between two specified dates. Syntax DateDiff ( interval, date1, date2 [, firstdayofweek] [, firstweekofyear] ) interval can be any of the intervals defined in the DatePart() function date1 and date2 are the two ...
CDate() CDate() converts something from any datatype to a Date datatype Sub CDateExamples() Dim sample As Date ' Converts a String representing a date and time to a Date sample = CDate("September 11, 2001 12:34") Debug.Print Format$(sample, "yyyy-mm-dd hh:nn:...

Page 1 of 1