How to convert a string to a date - .NET sample code
public string GetAnalysisTimeDuration(string strFromDate, string
strToDate)
{
string
strDuration = "";
try
{
DateTime dateStart
= Convert.ToDateTime(strFromDate);
DateTime dateEnd = Convert.ToDateTime(strToDate);
if
(dateStart.Year != dateEnd.Year)
strDuration = String.Format("{0:MMM
d,yyyy}", dateStart) + " - "
+ String.Format("{0:MMM
d,yyyy}", dateEnd);
else
strDuration = String.Format("{0:MMM
d}", dateStart) + " - "
+ String.Format("{0:MMM
d,yyyy}", dateEnd);
}
catch (Exception ex)
{
}
return
strDuration;
}
No comments :
Post a Comment