Click here to Skip to main content
15,886,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I need month number from string text.
ex: from "Aug 2014" , I should get 8, if "Jul 2014" then 7.

thanks,
Posted
Updated 4-Aug-14 2:05am
v2
Comments
Prasad Avunoori 4-Aug-14 8:06am    
So, All string looks like Jan 2014, Feb 2014, Mar 2014, Apr 2014....?
Maciej Los 4-Aug-14 8:12am    
These strings come from...?
kk2014 4-Aug-14 8:34am    
string came from DB and bind to Drop down.

See this :
int month = DateTime.ParseExact("Aug 2014", "MMM yyyy", CultureInfo.InvariantCulture).Month;//month will be 8 in this case

Add reference to System.Globalization

Regards..
 
Share this answer
 
Comments
Maciej Los 4-Aug-14 10:09am    
+5
Thanks7872 4-Aug-14 10:35am    
Thanks Maciej :)
Maciej Los 4-Aug-14 16:18pm    
Do you have account on LinkedIn?
Thanks7872 5-Aug-14 1:51am    
Nope. I am about to create one.
Maciej Los 5-Aug-14 1:52am    
Let me know, when you finish it.
Refer below link

how-to-display-month-number-on-selecting-month-name[^]

Hope it will help..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900