Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date + 30 Days 2

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
I'm sending emails from sql server and need to only send results that are due 30 days from the time the email gets sent out.

so, in my table I have a column called due_date

I want to send out an email notification but only let the user know which due dates are coming up within the next 30 days from the date the notification gets sent out.

I've tried messing with the following and am stuck.

WHERE DUE_DATE = DATEADD(DAY, 30, GETDATE())

Any help would be appreciated

Thanks


 
What is the type of Due_Date?

Borislav Borissov
VFP9 SP2, SQL Server
 
You may want to keep from getting older stuff also but watch for time
Code:
WHERE DUE_DATE <= DATEADD(DAY, 30, GETDATE())
 AND DUE_DATE >= GETDATE()

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Or, if you prefer (this works in SQL Server 2012):

SQL:
[COLOR=#0000FF]WHERE[/color] DUE_DATE [COLOR=#FF0000]BETWEEN[/color] [COLOR=#00B0B0]CONVERT[/color](DATE, [COLOR=#00B0B0]GETDATE[/color]()) [COLOR=#FF0000]AND[/color] [COLOR=#00B0B0]CONVERT[/color](DATE, [COLOR=#00B0B0]GETDATE[/color]() + [COLOR=#FF0000]30[/color])

This strips the time so you can use BETWEEN. And the + 30 just adds 30 days to today's date.

-- Francis
Francisus ego, sed non sum papa.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top