Date Math In SQL Server, Number of Days Elapsed Since Date In Table

I am fairly new to SQL Server, working in SQL Developer 14.

I have a requirement to pull records from a table after a specified number of days has passed.

I have a lot of experience in MS Access and I could accomplish this in an Access query using the Date Function.  'TableDate' is the field containing the date.  If I wantto make sure at least 30 days have passed:

Select .....
From ....
Where Date - TableDate > 30

Is there a way to do something similar in a SQL Select?
Who is Participating?
Always choose a method that does NOT require a function on the data. There are many reasons for this
 * in most cases it removes the ability to use an index on the column being amended (makes the query slower)
 * requires a function call on every row, quite unnecessarily

please choose this approach:

FROM YourtableName
WHERE TableDate > CAST((GETDATE() - 30) AS DATE)

notice that it doesn't alter the table data, instead it does just one calculation
Pawan KumarDatabase ExpertCommented:
Please try like this-

DateDiff function.

FROM YourtableName

Open in new window

OR this

FROM YourtableName
WHERE TableDate > CAST((GETDATE() - 30) AS DATE)

Open in new window

mlcktmguyAuthor Commented:
Thanks for the comments and suggestions, they are very much appreciated.  I took some time off over the holiday so I have not had time to evaluate them yet.
mlcktmguyAuthor Commented:
Thank You
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.