on 11-20-2018 9:46 PM
Hi Experts,
Will you be able to help me come up with a SQL query that will compute for the next date based on the Recurrence, Interval and Day of week in the Activity (OCLG).
Here's an example:
The Activity is Set to Weekly with an Interval of 1 and the Day of Week is Thursday. The screen on the right is a sample of the list of next dates for the next 6 months. I need a query that will calculate for this that is dependent on the Recurrence (Daily, Weekly, Monthly, Annually) and the interval that can be saved on a #Temp Table. Is this something possible? Thanks in advance
Maria
Dear Maria,
Try this Query;
DECLARE @date DATETIME, @Weaks INT
SET @date = '2018-11-15 00:00:00'
SET @Weaks = 5;
WITH TEST AS (SELECT 0 AS DAY UNION ALL SELECT DAY + 1 FROM TEST WHERE DAY < @Weaks -1 )
SELECT DATEADD(WK,DAY,@date) FROM TEST
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.