You can also use IFormatProvider to parse your variable to datetime with the specified format.
Below is the sample code....
The format variable can have any format type like
string sFormat = ""dd/MM/yyyy";
public string GetFormattedDate(string date, string sFormat)
{
string fdate = "";
try
{
if (date != "")
{
IFormatProvider f = new CultureInfo(DATECULTURE, false);
DateTime d = DateTime.Parse(date, f);
fdate = d.ToString(sFormat);
}
}
catch
{
}
return fdate;
}