Monday, April 22, 2013

Function for converting text to datetime(c#)


DateTime curMarrCerDate = Utility.ToFormalDateFormat_D(TxtMarCertDate.Text);

public static DateTime ToFormalDateFormat_D(string strDate)
{
       string[] dateStr = strDate.Split(SPLITER_2);
       strDate = string.Format(DATE_FORM, dateStr[1], dateStr[0], dateStr[2]);
       return Convert.ToDateTime(strDate);
}

public const char SPLITER_2 = ‘/’;


reference : http://dev1.wordpress.com/2007/08/30/function-for-converting-text-to-datetimec/

No comments:

Post a Comment