Jeff Uchtman wrote:
Not sure if this is the right group. Have a XML wiht date coming in the
following format:
<date_MMDDYYYY>
Have a function pulling numbers
function getDate(d) {
return d.slice(5,7) + '/' + d.slice(7,9) + '/' + d.slice(9);
}
Would like to convert to long date, i.e August 29, 2006.
Look at the DateTime struct. There's a constructor that takes year,
month, day as integers. You can then return the DateTime's
ToString("D"), or ToLongDateString.
Untested code that assumes it has valid input:
function string GetDate(string date_MMDDYYYY)
{
int Year = Convert.ToInt32(date_MMDDYYYY.Substring(9, 4));
int Month = Convert.ToInt32(date_MMDDYYYY.Substring(5, 2));
int Day = Convert.ToInt32(date_MMDDYYYY.Substring(7, 2));
DateTime Date = new DateTime(Year, Month, Day);
return Date.ToLongDateString();
}
--
..NET 2.0 for Delphi Programmers
www.midnightbeach.com/.net
Delphi skills make .NET easy to learn In print, in stores.