sql: current date - 60?

hi all

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

how can i do this?
malraffAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
>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
 
Ashok KumarCommented:
DATEDIFF(month, @date, getdate())<3
something like this.
0
 
mamalik00Commented:
MSSql Server

 select datepart(mm,getdate()) - 3
 
this query will return you the current month - 3
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Ashok KumarCommented:
you need to use the condition in your update where clause.
0
 
Atdhe NuhiuCommented:
update yourtable
set yourfield=value
where datefield < dateadd(mm,-3,getdate() )
0
 
malraffAuthor Commented:

 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.