0

Hi,

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

thanks,

3
Contributors
4
Replies
41
Views
3 Years
Discussion Span
Last Post by AffineMesh
0

First you need to split the string by the blank space and get the first part.
Then you create an Select Case or an If...Else If.

Dim original = "Aug 2014"
Dim str = Split(original, " ")(1)
Dim month = 0

if str = "Aug" Then
    month = 8
else if str = "Jul" Then
    month = 7
else if
.
.
.
0

Hi AleMonteiro,

I have not fixed string of months. any month can come from DB.

finally i found 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,

0

Krunal, did you mean to post in the ASP forum? DateTime is part of the .NET Framework - it'll work under ASP.NET but not ASP.

Edited by AffineMesh

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.