March 27, 2008 at 1:54 am
If your date columns are defined datetime you're OK with this proc.
create proc usp_thedeletes
as
begin
set nocount on
delete
from yourtable
where datediff(d, From_Date, To_Date) > 30
end
Else, don't come complaining that the columns contain invalid dates !
If your date columns are defined (var)char, you'll have to convert them to datetime using
datediff(d, convert(datetime, From_Date, 103 ) , convert(datetime, To_Date, 103 ) ) > 30
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data and code to get the best help
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
March 27, 2008 at 2:34 am
Also asked and answered here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=99743
N 56°04'39.16"
E 12°55'05.25"
Viewing 2 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply