Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Ho do I calculate date plus days without weekends in Table Transformer SQL

I'm looking to have a table with one column of dates, another column of days and the 3rd column calculated by adding the two and excluding the weekends.   Say if date Jan 1 falls on a Monday and i need to add 8 days, the resulting 3rd column will be Jan 10 (Wed the following week).  I followed the following article but it is a straight days add.

https://community.atlassian.com/t5/Confluence-questions/Calculating-dates-from-a-start-date/qaq-p/930126

Thanks in advance for your help

1 answer

1 accepted

Hi @Fulbert Lato ,

You may try the following SQL query:

Tue 2-1.pngSELECT *,
FORMATDATE(DATEADD(day,
T1.'Period' +
2 * FLOOR(T1.'Period' / 5) +
CASE
WHEN 'Start Date'::Date->getDay() = 0 THEN 1
WHEN 'Start Date'::Date->getDay() = 6 THEN 2
WHEN ('Start Date'::Date->getDay()) + T1.'Period' % 5 > 5 THEN 2
ELSE 0
END,
T1.'Start Date'))
AS 'End Date'
FROM T1

Tue 2-2.pngThe query counts the number of Saturdays and Sundays for your period plus checks if the Start Date belongs to the weekend and "extends" the period (i.e. moves the End Date further) for the calculated number of holidays.

That is brilliant!  Thank you!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

🥓🙅🏻‍♀️ Meet-less May Badge!

Hello Confluence Community!  What if i told you that you could have a healthier life and be 100% meet-less? This month, we're promoting a healthy, balanced work diet with Confluence. (Read m...

351 views 3 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you