How to Find out Third Friday of Given Month

Hi All,

I want to find out Third Friday of the specific month. Can anyone help me in resolving this please?

1 Like

Hi

You can use this expression in a assign activity like this

Str_date = DateTime.Today.AddDays((18 - DateTime.Today.DayOfWeek + 7) Mod 7).ToString

If you want as a Datetime type itself then don’t put .ToString

Cheers @Aswini

@Palaniyappan

I tried using this but its giving me 27th of this month. But I want 21st as the result

Find the first Friday of the month (it’s one of the days between 1th and 7th). Then add 14 to get the 3rd Friday.

1 Like

Try modifying the same expression like this

New DateTime(year, month, 1).AddDays((18 - CInt(New DateTime(year, month, 1).DayOfWeek)) Mod 7 + 14)

Cheers @Aswini

Unfortunately the above expression giving me error.

@Palaniyappan

Fine can u share the screenshot of the erro

@Aswini

Lets assume a variable CheckDate representing a DateTime (e.g. Today)

check with another Date:

Enumerable.Range(1,DateTime.DaysInMonth(CheckDate.Year, CheckDate.Month)).Select(Function (x) new DateTime(CheckDate.Year, CheckDate.Month,x)).Where(Function (x) x.DayOfWeek = 5)(2)

Depending on some constraints we can also modify and maybe compacting the statement

1 Like

Please finf the screenshot of the error

@Palaniyappan

Its working. Thank you @pp

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