SQL formula current month plus/minus X days, not including weekends.

Query

I have a custom one for Period Closing Activities. The user clicks a button at the beginning of the month-end period, and the record populates a sub-list of 20 tasks. Currently, the owner of each task comes in and puts an expected end date. But I want to automatically fill in the expected end date field.

I need SQL to use in a formula field to say end of current month plus/minus X days, not including weekends.

Can someone help on how I would achieve this, please?

Solution

You can start with:

Formula (Numeric) = CASE WHEN (to_char(LAST_DAY({today}) + N,’D’) = ‘7’) THEN LAST_DAY({today}) + N + 2

WHEN (to_char(LAST_DAY({today}) + N,’D’) = ‘1’) THEN LAST_DAY({today}) + N + 1

ELSE LAST_DAY({today}) + N END

Note: Replace +N with your requirements.

Leave a comment

Your email address will not be published. Required fields are marked *