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

VBA Macro For VLOOKUP From Another Sheet
vba macro for vlookup from another sheet1

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
remove special character2

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
insert commetns in protected workshee3

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
convert text to upper cases1

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 ...

How To Hide Every Other Row in Excel (Using VBA)
hide every other row1

This post will show you how to hide alternate rows or columns in Excel or how to hide every third, fourth, fifth row or column in Excel. If you want to hide every other row in your current worksheet, how ...

How to Disable the Save As Prompt in Excel
disable save as prompt1

This post will show you how to use a VBA Macro to save an Excel file and overwrite any existing file without a prompt so that you are going to get the little window that says file already exists do ...

How to Count Cells that Contain even or odd numbers in Excel
count cells that contain even numbers5

This post will guide you how to count the number of cells that contain odd or even numbers within a range of cells using a formula in Excel 2013/2016.How do I count cells that contain odd numbers through the use ...

How to Count Cells Are Not Blank or Empty in Excel
count non blank nonempty cells5

This post will guide you how to count cells that are not blank or empty in a given range cells using a formula in Excel 2013/2016.How do I count the number of cells that are not blank in a particular ...

How to Count Cells Less Than a Specific Value in Excel
count cells lessr than5

This post will guide you how to count the number of cells less than a particular numeric value in a given range cells using a formula in Excel 2013/2016. How do I count cells that are less than a specific ...

How to Count Cells Greater Than a Specific Value in Excel
count cells greater than 5

This post will guide you how to count the number of cells greater than a particular numeric value in a given range cells using a formula in Excel 2013/2016. How do I count cells that are greater than a specific ...

Sidebar