?
Solved

sql: current date - 60?

Posted on 2010-08-16
6
Medium Priority
?
401 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
Independent Software Vendors: 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 2000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

801 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