you can build a function to convert that, I use this (I never saw an
auomatic convertion on behalf of the framework, maybe someone knows)
Use:
Dim myNewDate as String = convertDateTypes("12/01/2006", "DMY")
String myNewDate = convertDateTypes("12/01/2006", "DMY");
Code in VB and C#:
-------------------------------------------------------------------------
''' <summary>
''' converts a string with a date into diferent format
''' </summary>
''' <param name="sDate">Date to be converted</param>
''' <param name="sType">Convert date to... (MDY or DMY)</param>
''' <returns></returns>
''' <remarks></remarks>
Function convertDateTypes(ByVal sDate As String, ByVal sType As String) As
String
' MDY = mm/dd/yyyy
' DMY = mm/dd/yyyy
Dim sResponse As String = ""
Dim sSeparator As String = "/"
If sType = "MDY" Then
' convert from DMY to MDY
Dim sDay As String = sDate.Substring(0, 2)
Dim sMon As String = sDate.Substring(3, 2)
sResponse = sMon & sSeparator & sDay & sSeparator &
sDate.Substring(sDate.Length - 4, 4)
Else
' convert from MDY to DMY
Dim sDay As String = sDate.Substring(3, 2)
Dim sMon As String = sDate.Substring(0, 2)
sResponse = sDay & sSeparator & sMon & sSeparator &
sDate.Substring(sDate.Length - 4, 4)
End If
Return sResponse
End Function
-------------------------------------------------------------------------
/// <summary>
/// converts a string with a date into diferent format
/// </summary>
/// <param name="sDate">Date to be converted</param>
/// <param name="sType">Convert date to... (MDY or DMY)</param>
/// <returns></returns>
string convertDateTypes(String sDate , String sType ) {
// MDY = mm/dd/yyyy
// DMY = mm/dd/yyyy
string sResponse = "";
string sSeparator = "/";
if ( sType == "MDY" ) {
// convert from DMY to MDY
string sDay = sDate.Substring(0, 2);
string sMon = sDate.Substring(3, 2);
sResponse=sMon + sSeparator + sDay + sSeparator +
sDate.Substring(sDate.Length-4, 4);
}
else {
// convert from DMY to MDY
string sDay = sDate.Substring(3, 2);
string sMon = sDate.Substring(0, 2);
sResponse=sMon + sSeparator + sDay + sSeparator +
sDate.Substring(sDate.Length-4, 4);
}
return sResponse;
}
--
Bruno Alexandre
København, Danmark
"a portuguese in Denmark"