Solved

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

Posted on 2009-05-15
2
780 Views
Last Modified: 2013-12-07
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
Comment
Question by:Saroj13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 21

Expert Comment

by:JestersGrind
ID: 24399235
Try this:

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

Greg


0
 
LVL 13

Accepted Solution

by:
St3veMax earned 500 total points
ID: 24399340
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

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to take different types of Oracle backups using RMAN.

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question