question

technette avatar image
technette asked

Select rows where due in 15 days

I need to select all rows where estimates are due in fifteen days from the given quote date. How do I do this?
dateadd
10 |1200

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

Squirrel avatar image
Squirrel answered
SELECT * FROM yourtable WHERE estimate_date
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.

technette avatar image technette commented ·
Thank you. I did a slight modification: Select DATEADD(DAY, 15, QuoteDate) As DueDate Then I gave a report with all quotes created in the past 30 days which showed the DueDate.
0 Likes 0 ·
DenisT avatar image
DenisT answered
DECLARE @T1 TABLE ( Id INT NOT NULL , EstDate DATE NOT NULL ); INSERT INTO @T1 VALUES ( 1, DATEADD(DAY, -1, GETDATE()) ), ( 2, DATEADD(DAY, 15, GETDATE()) ), ( 3, DATEADD(DAY, 15, GETDATE()) ), ( 4, DATEADD(DAY, 14, GETDATE()) ), ( 5, DATEADD(DAY, 14, GETDATE()) ), ( 6, DATEADD(DAY, 16, GETDATE()) ), ( 7, DATEADD(DAY, 16, GETDATE()) ), ( 8, GETDATE() ); SELECT * FROM @T1 t; SELECT * , CAST(GETDATE() AS DATE) AS [QuoteDate] , CAST(DATEADD(DAY, 15, GETDATE()) AS DATE) AS [QuoteDate+15] FROM @T1 t WHERE t.EstDate >= CAST(GETDATE() AS DATE) AND t.EstDate
10 |1200

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

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.