I want current month Friday count based on current day

Today date is 07/25/2024

I expected Output is 3.
Reason is already this month 3 Friday went.

July -5 Friday
July - 12 Friday
July - 19 Friday

Output 3

Tomorrow I will check 07/26/2024

I expected Output is 4
Reason is already this month 3 Friday went.

July -5 Friday
July - 12 Friday
July - 19 Friday
July - 26 Friday

Hi @AJITH_SK

inputDate = DateTime.Parse("07/25/2024")
fridaysCount = Enumerable.Range(1, inputDate.Day).
    Count(Function(day) New Date(inputDate.Year, inputDate.Month, day).DayOfWeek = DayOfWeek.Friday)

Regards

One way to do it using activities:

1 Like

Hi @AJITH_SK

Check the below flow for better understanding:

If input Date is 07/25/2024

inputDate = DateTime.Parse("07/25/2024")
fridaysCount = Enumerable.Range(1, inputDate.Day).
    Count(Function(day) New Date(inputDate.Year, inputDate.Month, day).DayOfWeek = DayOfWeek.Friday)

If input Date is 07/26/2024

inputDate = DateTime.Parse("07/26/2024")
fridaysCount = Enumerable.Range(1, inputDate.Day).
    Count(Function(day) New Date(inputDate.Year, inputDate.Month, day).DayOfWeek = DayOfWeek.Friday)

The same syntax will work for both the dates and print the expected output.
Let me know if you have any issues.

Regards

@AJITH_SK

Enumerable.Range(1, today.Day).Count(Function(day) New DateTime(today.Year, today.Month, day).DayOfWeek = DayOfWeek.Friday)

Please Try this

Getting below error

Hi @AJITH_SK

Try this:

DataType:

Regards

Getting error

@AJITH_SK

Try to remove Microsoft.Graph Namespace from Import panel

Hi @AJITH_SK

Please go to Imports Panel right click on Microsoft.Graph namespace and Delete it your error will be gone.

Regards

As mentioned in the error, it is ambigious so make it more qualified:
System.DayOfWeek.Friday

1 Like

Working fine expected

Hi @AJITH_SK

You can try the below syntax without removing Microsoft.Graph from Imports Panel since once that particular namespace is imported you can’t delete that namespace.

Enumerable.Range(1, inputDate.Day).Count(Function(day) New Date(inputDate.Year, inputDate.Month, day).DayOfWeek = System.DayOfWeek.Friday)

Hope you understand!!
Regards

1 Like

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