Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Retrieving last 14 months of data with SQL statement

Posted on 2006-06-29
3
Medium Priority
?
368 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 1400 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 600 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

715 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