Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sql: current date - 60?

Posted on 2010-08-16
6
Medium Priority
?
407 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

604 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