I am getting date as April,1,2009. I want to format the date so that the month is displayed as 4. Not only for the date given above but for whatever date is given. Can anybody give appropriate code?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To get just the month as an integer, you could use this.
Of course you’ll want to make sure inputDate is valid. For that you can use DateTime.TryParse instead of DateTime.Parse.