OzGrid

Convert to a Date Data Type

< Back to Search results

 Category: [Excel]  Demo Available 

Convert to a Date Data Type

 

Excel VBA: Convert to a Date Data Type

Got any Excel/VBA Questions? Free Excel Help.

The example below shows how CDate can be used in Excel VBA to convert a number or text string to a Date data type.

Sub ConvertToDate()

Dim lNum As Long

Dim strText As String



lNum = 38543

MsgBox CDate(lNum)



strText = "February 14, 1995"

MsgBox CDate(strText)



strText = "5:45:55 PM"

MsgBox CDate(strText)



End Sub

 

Free Training Course: Lesson 1 - Excel Fundamentals

 

See also: Index to Excel VBA Code; Index to Excel Freebies; Lesson 1 - Excel Fundamentals; Index to how to… providing a range of solutions

 

Microsoft ® and Microsoft Excel ® are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft

 

See also:

Convert a String or Number to Boolean
Convert a String to a Byte Data Type
Convert to a Currency Data Type
Convert to a Decimal Data Type
Convert to a Double Data Type
Convert to a Integer Data Type
Excel VBA: Convert to a Long Data Type
Convert to a Single Data Type
Convert to a String Data Type
Convert Excel Text To Upper Case

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)