VBA Date and Time Function

VBA Date and Time Functions in Excel

VBA Date and Time Functions in Excel. 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

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays in Excel Blog

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers

3 thoughts on “VBA Date and Time Functions in Excel”

  1. how can i auto entry of date for two or more people in same work sheet?
    for eg
    person a person B
    sn date description rate sn date description rate
    1 1/31 rent 20000 1 1/5 phone bill 5000
    thanks in advance…

  2. how can i auto entry of date for two or more people in same work sheet?
    for eg
    person a
    sn date description rate
    1 1/31 rent 20000
    person b
    sn date description rate
    1 1/5 phone bill 5000
    thanks in advance…

Leave a Reply