string _StartDate = "20120707";
if (!String.IsNullOrEmpty(StartDate))
{
DateTime _ExpiryDate = DateTime.ParseExact(_StartDate, "yyyyMMdd", DateTimeFormatInfo.InvariantInfo);
}
This will convert 20120707 to 7/7/2012 12:00:00 AM
Now given _ExpiryDate as 7/7/2012 12:00:00 AM, The following will convert from Date to yyyymmdd format
_ExpiryDate.ToString("yyyyMMdd", System.Globalization.CultureInfo.GetCultureInfo("en-US"));
No comments:
Post a Comment