Solved

sql: current date - 60?

Posted on 2010-08-16
6
388 Views
Last Modified: 2012-05-10
hi all

i want to update data 3 months older than the current date

how can i do this?
0
Comment
Question by:malraff
[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
6 Comments
 
LVL 6

Expert Comment

by:Ashok Kumar
ID: 33444666
DATEDIFF(month, @date, getdate())<3
something like this.
0
 
LVL 3

Expert Comment

by:mamalik00
ID: 33444667
MSSql Server

 select datepart(mm,getdate()) - 3
 
this query will return you the current month - 3
0
 
LVL 6

Expert Comment

by:Ashok Kumar
ID: 33444670
you need to use the condition in your update where clause.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 33444672
>3 months older
as suggested by above comments, please clarify what exactly means "3 months" ...


"exactly" 3 months ago:
dateadd(month, -3, getdate())


however, you might want to take only full months ?
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 33444678
update yourtable
set yourfield=value
where datefield < dateadd(mm,-3,getdate() )
0
 

Author Comment

by:malraff
ID: 33444735

 select datepart(mm,getdate()) - 3 still returned 2010-08-05 00:00:00.000

angel -- yours works 100%, i want exactly 3 months as you provided!
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Parsing the XML data to SQL Server 4 70
SQL Agent Timeout 5 69
Replication failure 1 23
Better way to filter date  - Query 5 25
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 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