question

rpowell avatar image
rpowell asked

Get the correct workday based on a table of valid business day

I have a table of valid Calendar Days . I would like to pass a date, and arrive at a valid Calendar Day based on my calendar below.

For example. I will pass the Calendar Day 09/03/2021. Then I would like get the 10th valid Calendar Day from 09/03/2021, which includes 09/03/2021. The 10th valid Calendar Day from 09/03/2021 should be 09/17/2021.

I gather I could use either a CURSOR or WHILE loop. What would be the best way to code this in TSQL?

Calendar

1628628091682.png


tsqltable
1628628091682.png (21.6 KiB)
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Good lord. I was going to provide a solution base on your calendar table but it's a bloody graphic. Please provide that same info as a VALUES statement and I'll be happy to show you. I just don't liken to post anything i haven't tested.

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.