July 14, 2020 at 12:11 am
@Jeffrey Williams...
<li style="list-style-type: none;">
- Due to your hard-coded offsets for the start of each quarter, what's going to happen on a Leap Year?
Nothing - the hard-coded offsets are actually the integer value for the dates in the year 1900. They are not the number of days from the beginning of a year - so taking the difference in years between 0 (1900-01-01) and @fromDate will result in adding xx years to 1900-03-25 (83).
<li style="list-style-type: none;">
- Although probably not likely but still entirely possible, what's going to happen if the difference between @FromDate and @ToDate exceeds 100 months?
You are correct - if the date range exceeds 8+ years then this function will not work correctly. It is easy enough to modify by adding another t table to the cross join to increase the range if needed.
Good comment on the start date issue for the quarter. I was going to hum a rock at the OP on that one but then saw your good comment.
Why not sling a pork-chop?
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
July 14, 2020 at 1:57 am
Ah... understood on the offsets. Thanks, Jeff.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 14, 2020 at 7:46 am
Hi @Jeffrey Williams,
Wow, thank you for taking the time to put that together. I have tried it on my machine and it looks good. The production server this will run on is actually SQL 2008R2 so I think it will need tweaking to run on that as some of the functions are not compatible.
Thanks again to all who have looked and commented.
July 14, 2020 at 1:55 pm
You can remove the CONCAT function or modify to use + to build that string. That column isn't used.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy