[Last Call] Learn how to a build a cloud-first strategyRegister Now

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

Subtract two weeks from GETDATE.

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
Levi Martin
Asked:
Levi Martin
2 Solutions
 
Aneesh RetnakaranDatabase AdministratorCommented:
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
 
ophoCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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