How do I get the index of the month from its 3-letter abbreviation in VB.NET?

I am trying to get the month number from the month abbreviation (e.g. Jan, Feb, Mar). Here's what I've tried:

xdata(i) = DateTime.Parse(
               filteredData.Columns(i + 23).ColumnName.ToString
           ).ToString("m")

      

filterData strong> is a DataTable that has column names marked with month abbreviations. What's the best way to get the month number in this case?

+3


source to share


1 answer


Somthing like,

Dim monthNumber = DateTime.ParseExact(
                      "Jan",
                      "MMM",
                      CultureInfo.CurrentCulture).Month

      



Where "Jan"

is a valid abbreviation for the month in which you run your code.

+8


source







All Articles