Pick Info Based on Current Month

I have Data Like This

image

So Current Month is August, So I want to retrieve Data as

image

Once The Month Changes to September That is on the 1st of September that data should be retrieved as

image

Same Goes for October and So on

Any Help is appreciated :slight_smile:

Hi @Ishan_Shelke

Retrieved the September month

DateTime.Now = August

row("Column name").Tostring.Contains(DateTime.Now.Tostring("MM"))

Regards
Gokul

Hey!

Try this

  1. Read range - Dtout
  2. For each row in data table pass the Dtout
  3. Take one if condition and pass the expression like this
CurrentRow("ColumnName").ToString.Trim.Contains(Now.ToString("MM/yyyy"))

In then block you’ll get all the Current month Data
in Else block you’ll get the Remaining Data

Regards,
NaNi

Hi,

FYI, If we can add column headers in advance, as the following, we can extract it using column name.

Sample20220804-3.zip (9.7 KB)

Regards,

What If there were No Column Names Then How would we retrieve them ?

My Date Columns aren’t in Fixed Position Like in the above Sheet they are in the Columns C, D and E respectively, but sometimes they appear in the columns say G,H and I

Like Sometimes my data looks like this

image

Then How would we tackle this situation ?

1 Like

Hi,

If date format is always dd-MM-yyyy format, get the target column index, first, as the following.

colIndex = dt.Rows(0).ItemArray.Select(Function(o,i) if(DateTime.TryParseExact(o.ToString,"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None,New datetime) AndAlso DateTime.ParseExact(o.ToString,"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("yyyyMM")=Now.ToString("yyyyMM"),i,-1)).OrderBy(Function(i) i).Last()

Sample20220804-3 (2).zip (9.9 KB)

Regards,

@Ishan_Shelke

try this, you can also move the date columns around and it should still work

Book1.xlsx (9.6 KB)
test12334.xaml (14.0 KB)

before (Sheet1)

after (sheet2)

sorry, use this
test12334.xaml (22.5 KB)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.