Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 838
  • Last Modified:

Sql query to get data from last 30 days from today's date and time?

Hi,

I am using Sql Server 2005. I have a column Livedate. I want data which is added in the last 30 days from today's date and time.

Thanks
0
Saroj13
Asked:
Saroj13
1 Solution
 
JestersGrindCommented:
Try this:

SELECT *
FROM Table1
WHERE LiveData > GETDATE() - 30

Greg


0
 
St3veMaxCommented:
Or...

WHERE LiveData > dateadd(day, -30, datediff(d,0,GetDate()))

This will give you all results from the start of the day (i.e. 15/04/2009 00:00:00); Not results from -30 days ago at 15/04/2009 21:18 (the time I ran this)

HTH
0
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now