Hi,

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

thanks,

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
.
.
.

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,

You could try using CDate to convert the string. It seems to accept the format you want. Then just use the Month function to obtain a numeric value, e.g.

theDate = CDate("Jul 2014")
theMonth = Month(theDate)

See: Type Conversion Functions (Visual Basic).

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.