# How to extract specific data based on input frequency

Hi Team,

If frequency is Monthly. I need to extract the subject like For the Month of December 2023.
If I will run in January 2024 need to extract only Dec 2023.

For example I will run in March 2024 the subject will be For the Month of February 2024.

Need to extract Feb 2024 dynamically.

1. If frequency is Quarterly and I will run the flow in 1,4,7,10 months only and Subject like this For Q4, October through December 2023.

If I will in 1(January)in the subject need to Q4.
If run in 4 month bot need to extract Q1
Like this
Need to extract Q1, Q2, Q3 and Q4 based on Bot run in the month .

1. If frequency is Annually.
If I will run in January 2024 subject like this For January to December 2023.

Form that I need to extract Jan to Dec 2023

If I will run in Feb need to extract Fec to Jan 2024.

Kindly suggest

Hi @Baby123

Is the below solution is not worked for you, same query you have raised in the below post right.

Hi @mkankatala ,
It’s working. Thankyou @mkankatala but above one is different
Here I need to extract the month names and year .

Can you check my requirement.

Then could you please close the past thread, by mark my post as solution… @Baby123

Without doing your homework and providing a complete solution, a few tips on how I would approach this.

I see 3 different sub-use cases, so lets peel them off one by one.

1. given any month, you need to know the month before it.
So I could use the current date/input date, and simply use myInputDate.AddMonths(-1). This will calculate a new date, so it automatically takes care of changing years if you go from Jan → Dec

2. Here you have 2 desired dates, indicating the range of the quarter. So DateStart and DateEnd. DateEnd is easy, that is by default DateStart + 2 months (assuming we focus only on the months.
Determining the start date I would first calculate the 1st month of the quarter of the input date. You can do this by a full calculation, but since a year only has 12 months for the foreseeable future you could also just create a small static collection of the months per quarter.
Once you know the first month of the input quarter, the report start date is by default substracting 3 months from that date, turning Jan '23 into Oct '22. Then end date then Dec 22 by adding 2.

3. this one a combination of both. You know the input month. The end date is input month -1. the start date is the end date -11 (or input minus 12 whichever you prefer.

By using proper date/time datatypes these calculations allow you to derive month and year at your leisure.

You haven’t done at @Baby123

Check the below thread to know how to close the loop.

@Baby123

from any date if you need month name then `Date.ToString("MMMM")` and for year `Date.Year.ToString` will give the year

cheers

Hey @Baby123
here you can find working workflow:
BlankProcess90.zip (3.1 KB)