Excel VBA Data And Time

This post will guide you how to use VBA Date and time functions to convert date and time format in MS excel VBA.

There are many Date and time Functions, which can be used to convert date and time from one format to another very effectively in excel as bellows:

Date Function Description
Date Returns the current system date.
CDate Converts a value to date.
DateAdd Returns a date to which a specified time interval has been added.
DateDiff Returns the difference between two date values.
DatePart Returns a specified part of the given date
DateSerial Returns a date for the given year, month, and date value.
FormatDateTime Returns an expression formatted as a date or time.
IsDate Returns True or False whether the supplied parameter is a valid date.
Day Returns the day(1-31) of the specified date.
Month Returns the month (1-12) of the specified date.
Year Returns a four-digit year (from 1900 to 9999) of the specified date.
MonthName Returns the name of the particular month for the specified date.
WeekDay Returns a number (1 to 7) that represents the day of the week for a given date value.
WeekDayName Returns the weekday string name for the specified day.
Time Function Description
Now Returns the current system date and time.
Hour Returns the hours between 0 and 23 that represents the hour part of the given time.
Minute Returns the minutes between 0 and 59 that represents the minutes part of the given time.
Time Returns the current system time.
TimeSerial Returns the time for a specific hour, minute and second.
TimeValue Returns the serial number for a specific time

 

Related Posts

Find and Replace Multiple Values

This post will guide you how to find and replace multiple values at once with VBA macro or using formula  in Excel. How do I make multiple find and replace in Excel. Suppose that you have a few cells containing ...

VBA Macro For VLOOKUP From Another Sheet

In the previous post, you should know that how to fix or remove the #N/A error when using VLOOKUP formula to lookup value from another sheet. And this post will show you how to use VBA code to vlookup data ...

How To Remove Special Characters in Excel

This post will show you how to remove special characters from text strings in Excel. And I am going to introduce two ways to remove special characters (@&)#%$) from a string in Excel. Removing Special Characters using Power Query If ...

How To Insert Comments in Protected Worksheet in Excel

This post will show you how to allow comments in a protected worksheet in Excel. You can easily to insert comments into cells in a normal worksheet in Excel, but if want to insert a comment in a worksheet that ...

How To Convert Text to Upper Cases(Using VBA) in Excel

This post will show you how to switch from lower case to upper case in Excel. and I am going to show you two different ways of converting text to upper cases using formula or VBA macro in Excel 2013,Excel ...

Sidebar