Posts Tagged ‘Date Format’

How to Convert String to Date Format

To Convert String To Date Format, use the DateTime.ParseExact function

DateTime.ParseExact(s as String, format as String, provider As IFormatProvider) as DateTime

Parameters:

s
Type: System.String
A string that contains a date and time to convert. 
format
Type: System.String
A format specifier that defines the required format of s
provider
Type: System.IFormatProvider
An object that supplies culture-specific format information about s

Example:
 

  1.     Private Function ToDate() As DateTime
  2.  
  3.         Dim str As String = "20060505"
  4.  
  5.         Dim mDate As DateTime
  6.  
  7.  
  8.  
  9.         mDate = DateTime.ParseExact(str, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat)
  10.  
  11.         Return mDate
  12.  
  13.     End Function

Read More about DateTime.ParseExact Method (String, String, IFormatProvider)

,

No Comments



SetPageWidth