VBA Date and Time Function

VBA Date and Time Functions

VBA Date and Time Functions:

VBA Date and Time Functions help us to convert date and time from one format to another. These are DATE, DATEDIFF, DATEPART, DATESERIAL, DATEVALUE, DAY, HOUR, MINUTE, MONTH, NOW, TIME, TIMESERIAL, TIMEVALUE etc. Date & Time functions are Built-In functions. We can use these VBA Date and Time functions in either procedure or function. These functions we use in the VBA editor window in Excel. These Date and Time functions you can use any number of times in VBA macro codes.

List of Date and Time Functions in Excel VBA:

Here are the list of Date and Time functions. And also find its description, syntax and return type. We can use these multiple Date and Time functions in one statement.

Function Description Syntax Return Type
VBA Date VBA Date function returns current system date. Date() Date
VBA DateAdd VBA DateAdd function returns a date after which a certain time or date interval has been added. DateAdd(Interval, Number, Date) String
VBA DateDiff VBA DateDiff function returns the difference between two date values. It depends on the specified interval. DateDiff (Interval,Date1,Date2, FirstDayOfWeek,FirstWeekOfYear) Long
VBA DatePart VBA DatePart function returns a specified part of a supplied date or time DatePart(interval,date, [firstdayofweek],[firstweekofyear]) Integer
VBA DateSerial VBA DateSerial function returns date. DateSerial(year, month, day) Date
VBA DateValue VBA DateValue function returns the date value for specified string input. DateValue(date_value) Date
VBA Day VBA Day function returns day from date. Day(date_value) Integer
VBA Hour VBA Hour function returns hour from time. Hour(time_value) Integer
VBA Minute VBA Minute function returns Minute from time. Minute(time_value Integer
VBA Month VBA Month function returns month from date. Month(date_value) Integer
VBA MonthName VBA MonthName function returns a string representing the month given a number from 1 to 12. MonthName(Month,[Abbreviate]) String
VBA Now VBA Now function returns system date and time. Now() Date
VBA Time VBA Time function returns current system time. Time() Date
VBA TimeSerial VBA TimeSerialfunction returns time. TimeSerial(hour, minute, second) Date
VBA TimeValue VBA TimeValue function returns the date value for specified input represents date. TimeValue(time_value) Date
VBA Weekday VBA Weekday function returns a number representing the day of the week, given a date value. Weekday(Date,[FirstDayOfWeek]) Integer
VBA WeekdayName VBA WeekdayName function returns a string representing the day of the week given a number from 1 to 7. WeekdayName(Weekday,[Abbreviate],[FirstDayOfWeek]) String
VBA Year VBA Year function returns year from date. Year(date_value) Integer

List of VBA Functions:

Please click on below link to go back to see all List of VBA Functions.

Quick View of VBA Date and Time Functions List of VBA Functions

Leave a Comment

Your email address will not be published. Required fields are marked *