StringExtensions.AsDateTime Method
Include Protected Members
Include Inherited Members
Converts a string to a DateTime value.
This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.
Overload List
Name | Description | |
---|---|---|
AsDateTime(String) | Converts a string to a DateTime value. | |
AsDateTime(String, DateTime) | Converts a string to a DateTime value and specifies a default value. |
Top
Remarks
The AsDateTime method overloads convert a variety of date or time string values to a DateTime value. For example, the methods can convert the following date and time strings:
Universal Coordinated Time (UTC) strings such as 12/8/2010 5:48:05 PM, where the time and date values are combined in the same string.
Date strings formatted in a variety of ways, such as March 1, 1997, 03/01/1997, and 03-01-1997.
Time strings formatted in a variety of ways, such as 3:00, 3:00 AM., 3:30 pm, 18:30, and 18:30:07.
Before you try to convert, you can check whether the string can be converted to this type by calling the IsDateTime(String) method, which returns true if the input string can be converted to this type.
If you pass an empty string ("") to an AsDateTime method, the method returns a DateTime time value of 1/1/0001 12:00:00 AM.