Hi all.
How do I convert string format month int numbered month.
For example how do i convert "Apr" into 05, or "Jan into 01.
Thanks in advance.
Alps
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
RealgarPosted Aug 25, 2005, 12:32 PM
string stringmonth = "Feb"; //or whatever you wish
int month = Convert.ToDateTime("01/"+stringmonth+"/2005").Month;
I think the first method was better though.
I´m not sure if there are other ways.
alpsPosted Aug 25, 2005, 10:40 AM
However I was thinking if a method already exists in the .NET classes,
may be in the DateTime classes somewhere.
RealgarPosted Aug 25, 2005, 8:25 AM
{
switch (month)
{
case "Jan":
return 1;
break;
case .....
...
case "Dec":
return 12;
break;
default:
return null;
break;
}
}