
- 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
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
VBA - CDate Function
The Function converts a valid date and time expression to type date.
Syntax
cdate(date)
Example
Add a button and add the following function.
Private Sub Constant_demo_Click() Dim a as Variant Dim b as Variant a = cdate("Jan 01 2020") msgbox("The Value of a : " & a) b = cdate("31 Dec 2050") msgbox("The Value of b : " & b) End Sub
When you execute the function, it produces the following output.
The Value of a : 1/01/2020 The Value of b : 31/12/2050
vba_date_time.htm
Advertisements