Solved

Retrieving last 14 months of data with SQL statement

Posted on 2006-06-29
3
367 Views
Last Modified: 2011-09-20
I have a query that currently pulls all data since May of 2005.  The report that utilizes this data only needs 14 months of data to run.  How can I set up the query below to pull only the last 14 months of data going back from the current date?  Preferably the solution will be placed within the where statement.  All queries are run from MS Query within Excel XP.  Thanks in advance.


Select *
From Table A
Where fundeddate>'20050430'
0
Comment
Question by:srejja
[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
3 Comments
 
LVL 18

Expert Comment

by:ShogunWade
ID: 17013924
Select *
From Table A
Where fundeddate<DATEADD(month,-14,getdate())
0
 
LVL 18

Accepted Solution

by:
ShogunWade earned 350 total points
ID: 17013927
correction:

Select *
From Table A
Where fundeddate>=DATEADD(month,-14,getdate())
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 150 total points
ID: 17015985
if you want the full month (starting from day 1 of that month:

declare @startdate datetime
set @startdate = DATEADD(month,-14,getdate())
set @startdate = DATEADD(day,1-datepart(day,@startdate),@startdate)
set @startdate = convert(datetime, convert(varchar(10), @startdate,120), 120)

Select *
From Table A
Where fundeddate>@startdate
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

632 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