Hi all
I want to create a method that converts from one time or date format (as a string) to another by specifying the inputformat and the outputformat. I can do the output as below but I'm struggling on how to specify what the input format is. Can anyone help?
thanks.
//I'm halfway there.
string date = FormatDateTime(myDate, "yyyyMMdd"));
string time = FormatDateTime(myTime, "HHmm"));
private string FormatDateTime(string dateortime, string outputformat)
{
string ret = "";
if (dateortime == "")
return "";
try
{
ret = System.Convert.ToDateTime(dateortime).ToString(outputformat);
}
catch
{
}
return ret;
}