Solved

Subtract two weeks from GETDATE.

Posted on 2007-03-26
2
1,429 Views
Last Modified: 2010-02-26
So I have the below query and I want to return a date but take it two weeks back so if the date taken is 3/26/2007 the date value used is 3/12/06. How may I accomplish this task?

select intBranchID, txtOrderSubType, sum(mnyActivityLaborPay + mnyLaborRevenue)
from tblSiebelComplete1000
where dteActualEndDate between SUBTRACT TWO WEEKS BACK (GETDATE)
group by intBranchID, txtOrderSubType
0
Comment
Question by:Levi Martin
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 250 total points
ID: 18794638
select intBranchID, txtOrderSubType, sum(mnyActivityLaborPay + mnyLaborRevenue)
from tblSiebelComplete1000
where dteActualEndDate between CAST(CONVERT(VARCHAR, GETDATE(),112) AS DATETIME)-14  AND GETDATE()
group by intBranchID, txtOrderSubType
 
0
 
LVL 4

Assisted Solution

by:opho
opho earned 250 total points
ID: 18794646
select
  intBranchID,
  txtOrderSubType,
  sum(mnyActivityLaborPay + mnyLaborRevenue)
from
  tblSiebelComplete1000
where
  dteActualEndDate between dateadd(week, -2, getdate()) and getdate()
group by
  intBranchID,
  txtOrderSubType

Like that?

--Steve
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DTS Connection Failed 7 70
Get the latest status 8 32
awk and Pythagoras? 5 7
syntax sql error 2 13
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

777 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