Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 where date greater than one year from today

Author  Topic 

feelingsheepish
Starting Member

8 Posts

Posted - 2009-09-01 : 09:19:18
Hi,

I would like to be able to select all records from a table where the date is greater than one year from todays date. Can someone show how to go about doing this?

The field is in datetime format.

Many thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-01 : 09:29:51

where datecol>dateadd(year,1,getdate())

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-09-01 : 09:36:20
shouldn't it be -1?

this?

where [urcolumn] > dateadd(yyyy,1,datediff(dd,0,getdate()))

EDIT : Oops ...sorry..dint notice OP's post saying "one year from today's date"
Go to Top of Page

feelingsheepish
Starting Member

8 Posts

Posted - 2009-09-03 : 05:09:45
quote:
Originally posted by madhivanan


where datecol>dateadd(year,1,getdate())

Madhivanan

Failing to plan is Planning to fail



Thanks, thats great
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-03 : 05:12:57
quote:
Originally posted by feelingsheepish

quote:
Originally posted by madhivanan


where datecol>dateadd(year,1,getdate())

Madhivanan

Failing to plan is Planning to fail



Thanks, thats great


You are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -