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
 General SQL Server Forums
 New to SQL Server Programming
 how to get dates within certain # of days

Author  Topic 

jept
Starting Member

14 Posts

Posted - 2007-04-16 : 13:02:46
Hello,
I have a table with a field Expiration of smalldatetime. I want to only display the data that has 60 days or more between Expiration and todays date. Any help would be highly appreciated.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-04-16 : 13:05:29
select * from MyTable
where Expiration > getdate()-60

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-16 : 13:05:48
select *
from table1
where expiration < dateadd(day, -60, current_timestamp)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-16 : 13:06:11
[code]
select *
from table
where expiration >= dateadd(day, +60, getdate())
[/code]


KH

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-04-16 : 13:08:29
quote:
Any help would be highly appreciated.

Too much help ?

Are you looking for future expiration of expired date ?


KH

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-04-16 : 13:09:19
LOL!

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -