How to get every monday date number from assign activity

how to get week number from assign activity

Like
First monday of date
second monday of date
third monday of date

thnks
shaik

@shaik.muktharvalli1

Can you please elaborate

cheers

@shaik.muktharvalli1
Can you eloberate your requirement

I have to get every first three week of monday date’s for every month

I have to get every first three week of monday date’s for every month

Hi @shaik.muktharvalli1

Try the below syntax:

Assign-> String.Join(vbCrLf, Enumerable.Range(1, 3).Select(Function(week) Enumerable.Range(1, 7).Select(Function(day) New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddDays((day - CInt(New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).DayOfWeek) + 7 * (week - 1)))).First().ToString("MM/dd/yyyy")).ToList())

Hope it helps!!

varibale type please

@shaik.muktharvalli1

Variable type is System.String.

Regards

@shaik.muktharvalli1

(From month In Enumerable.Range(1, 12)
 Let firstDayOfMonth = New DateTime(Datetime.Now.Year, month, 1)
 Let firstMonday = firstDayOfMonth.AddDays((DayOfWeek.Monday + 7 - firstDayOfMonth.DayOfWeek) Mod 7)
 Select {firstMonday, firstMonday.AddDays(7), firstMonday.AddDays(14)}).SelectMany(Function(x) x).ToList()


image

Hi @shaik.muktharvalli1

Can you try the below

String.Join(",", Enumerable.Range(1, 12) _
    .SelectMany(Function(month) Enumerable.Range(1, DateTime.DaysInMonth(DateTime.Now.Year, month)) _
        .Where(Function(day) New DateTime(DateTime.Now.Year, month, day).DayOfWeek = DayOfWeek.Monday) _
        .Take(3)) _
    .Select(Function(day) day.ToString()))

Cheers!!

@shaik.muktharvalli1

Please try this…this gives for current month …you can change it for any date you need

Enumerable.Range(1, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)).Select(Function(day) New DateTime(DateTime.Now.Year, DateTime.Now.Month, day)).Where(Function(d) d.DayOfWeek = DayOfWeek.Monday).Take(3).ToList() - this gives a list of dates

image

Hope this helps

cheers

Hi @shaik.muktharvalli1

Try This

  1. Inside the Sequence, add a For Each activity to iterate over each month.
  2. Use a Generate Data Table activity to create a DataTable to store the results.
  3. Within the For Each activity, use a While loop to find the first three Mondays of each month.
  4. Use DateTime functions to check if a date is a Monday and within the first three weeks of the month.
  5. Add the valid dates to the DataTable.

This will generates a DataTable with two columns: “Month” and “Mondays”. In the “Mondays” column, it stores the first three Mondays of each month as strings

Hi,

How about the following sample?

Sample
Sample20240222-4a.zip (2.7 KB)

Regards,

To get all the months use below syntax:

Assign-> Output = String.Join(Environment.NewLine, Enumerable.Range(1, 12).SelectMany(Function(month) Enumerable.Range(1, 3).Select(Function(week) Enumerable.Range(0, 7).Select(Function(day) New DateTime(DateTime.Today.Year, month, 1).AddDays((day + (week - 1) * 7) - CInt(New DateTime(DateTime.Today.Year, month, 1).DayOfWeek))).Where(Function(d) d.Month = month And d.DayOfWeek = DayOfWeek.Monday).FirstOrDefault())).Where(Function(d) d <> Nothing).Select(Function(d) d.ToString("MM/dd/yyyy")).ToList())

Output: System.String DataType

Hope it helps!!

I have to get first three monday date’s of month but 29 is january naa

please

Hi @shaik.muktharvalli1

Could you try this:
I think you need for all the months try this code:

Regards

how i can change each sheet name with this date’s

1 Like

@shaik.muktharvalli1

Please create a new topic. I will help you with that.

Regards

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