9 Replies Latest reply on Jun 12, 2018 8:33 AM by kumud.pandey

# Second weekday of every month

Hi All,

I need to find out date of second & fourth monday of every month, I can write a logic for all mondays in a month but I am sure there will be a very simple logic to derive this scenario.Please help me to identify this logic.

Thanks

• ###### 1. Re: Second weekday of every month

Hi, Jayakumar

It's not quite Very simple, but here is my approach.

Calculate "First Monday"

[YYYYMM]

year([Date])*100+month([Date])

[First Monday]

if datetrunc('month',{fixed[YYYYMM]:min([Monday])})

< datetrunc ('month',[Date])

then {fixed[YYYYMM]:min([Monday])}+7

else {fixed[YYYYMM]:min([Monday])}

end

Calculate 2nd and 4th

[2nd + 4th Monday]

if datetrunc('month',{fixed[YYYYMM]:min([Monday])})

< datetrunc ('month',[Date])

then {fixed[YYYYMM]:min([Monday])}+7

else {fixed[YYYYMM]:min([Monday])}

end

Thanks,

Shin

2 of 2 people found this helpful
• ###### 2. Re: Second weekday of every month

Sorry, the first Monday calc should be much simpler.

[First Monday]

date(datetrunc('week', datetrunc('month',[Date])+6, 'Monday'))

Thanks,

Shin

2 of 2 people found this helpful
• ###### 3. Re: Second weekday of every month

Thank you for your response. It really helps me.

• ###### 4. Re: Second weekday of every month

You are welcome.

Could you mark my answer as correct for other people know it's answered.

Thanks,

Shin

• ###### 5. Re: Second weekday of every month

Hi Shin,

Thanks a lot for this post and also for attaching your workbook.

Could you explain to me the logic for "{fixed[YYYYMM]:min([Monday])}".

Thanks,

Prithvi

• ###### 6. Re: Second weekday of every month

It seems like I pasted wrong  formula on [2nd + 4th Monday], anyways..

{fixed[YYYYMM]:min([Monday])}

In the each category of [YYYYMM}, always pick min of [Monday].

Actually [Monday] included last month's date as well and need to add other logic.

Thanks,

Shin

• ###### 7. Re: Second weekday of every month

Hi Shin,

Thank you for the explanation.

Taking your interpretation one step up, do you see anything wrong with the following formula for the 4th Monday.

datetrunc('week',datetrunc('month',order_date)+27,'Monday').

Regards,

Prithvi

1 of 1 people found this helpful
• ###### 8. Re: Second weekday of every month

That's same thing I believe.

Shin

1 of 1 people found this helpful
• ###### 9. Re: Second weekday of every month

Adding 7 will give 2nd Monday and so on

date(datetrunc('week', datetrunc('month',[Date])+6, 'Monday')) +7