
- VBA Tutorial
- VBA - Home
- VBA - Overview
- VBA - Excel Macros
- VBA - Excel Terms
- VBA - Macro Comments
- VBA - Message Box
- VBA - Input Box
- VBA - Variables
- VBA - Constants
- VBA - Operators
- VBA - Decisions
- VBA - Loops
- VBA - Strings
- VBA - Date and Time
- VBA - Arrays
- VBA - Functions
- VBA - Sub Procedure
- VBA - Events
- VBA - Error Handling
- VBA - Excel Objects
- VBA - Text Files
- VBA - Programming Charts
- VBA - Userforms
- VBA Useful Resources
- VBA - Quick Guide
- VBA - Useful Resources
- VBA - Discussion
VBA - DateSerial Function
A Function, which returns a date for the specified day, month, and year parameters.
Syntax
DateSerial(year,month,day)
Parameter Description
Year − A required parameter. A number between 100 and 9999 or a numeric expression. Values between 0 and 99 are interpreted as the years 1900 to 1999. For all other year arguments, use a complete four-digit year.
Month − A required parameter. It can also be in the form of an expression, which should range from 1 to 12.
Day − A required parameter. It can also be in the form of an expression, which should range from 1 to 31.
Example
Add a button and add the following function.
Private Sub Constant_demo_Click() msgbox(DateSerial(2013,5,10)) End Sub
When you execute the above function, it produces the following output.
10/05/2014
vba_date_time.htm
Advertisements