Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetDate( ) one year old

Status
Not open for further replies.

irate

Programmer
Jan 29, 2001
92
GB
I'm looking for an easy way put SELECT all records that are less than a year old.
Ive got something like this at the moment but i cant seem to concatenate them together.

SELECT DATEPART(yy,GETDATE() - 1 )
SELECT DATEPART(mm,GETDATE())
SELECT DATEPART(dd,GETDATE())

Does anyone know how to stick them together or of a way to get todays date minus 6 months in a less complicated way?
 
select* from xxx where x= dateadd(yy,getdate(),-1) John Fill
ivfmd@mail.md
 
Quick Q:

if i do DateAdd(mm,-6,GetDate()) on december ill get june,
but if its may then what happens? does it take one of the year automatically???
 
Yes. Dateadd will not confine you to the current year. It will go back 6, 16, 26 months, whatever.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top