Afternoon all,
As the title says really... I'm looking to compute the date for Friday next week. So basing the following calaculations on today / this week (Monday 24/06/2019 & Friday 28/06/2019)
This should give me date for monday next week:
SELECT
CONVERT(DATE, DATEADD(DAY, (DATEDIFF(DAY, 0, '2019-06-24') / 7) * 7 + 7, 0), 103) AS DateNextMonday
Which works absolutly fine, what ever day I run it this week I get the date for Monday next week.
However, getting the date for friday next week isn't proving quite so simple... By my calculations this should give me the date for Friday next week:
SELECT
CONVERT(DATE, DATEADD(DAY, (DATEDIFF(DAY, 4, '2019-06-24') / 7) * 7 + 7, 4), 103) AS DateNextFriday
This works OK until its run on Friday, Saturday or Sunday this week:
SELECT
CONVERT(DATE, DATEADD(DAY, (DATEDIFF(DAY, 4, '2019-06-28') / 7) * 7 + 7, 4), 103) AS DateNextFriday
It then gives the answer as Friday, week after next...
Have I made an error in my calculations, or am i missing a trick??
Thanks in advance...
Dave