hubfub
asked on
PROC SQL: Delete rows in which two date fields differ by more than 250 days
Hi all, I;m not familiar with PROC SQL (I think its similar to MS SQL)
I am running a statistics program called SAS and am trying to delete certain rows in a database. The fields 'Date_Announced' and 'Date' are the ones I am concerned with. I'm trying to subtract the two coloumns and then delete the rows for which the result is >250 . The sheet is called Asx.mergernew.
Can someone help me with the exact command to type into my command window?
I am running a statistics program called SAS and am trying to delete certain rows in a database. The fields 'Date_Announced' and 'Date' are the ones I am concerned with. I'm trying to subtract the two coloumns and then delete the rows for which the result is >250 . The sheet is called Asx.mergernew.
Can someone help me with the exact command to type into my command window?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI RiteshShah
DATEDIFF is not a command that is recognised nor is it a field. Is there a way to get around this? One field in ours is Date and the other is Date_Announced. What is dd?
DATEDIFF is not a command that is recognised nor is it a field. Is there a way to get around this? One field in ours is Date and the other is Date_Announced. What is dd?
DATEDIFF is a date function built in in SQL Server, "DD" gives you difference in days.
can't you even run below command?
can't you even run below command?
select DATEDIFF(dd,getdate()-250,getdate())
ASKER
When I run that command it says 'syntax error'
I am trying to run these commands in a statistics program called SAS although the command window says PROC SQL - is this why the commands are not running?
I am trying to run these commands in a statistics program called SAS although the command window says PROC SQL - is this why the commands are not running?
those command should run in SQL Server, not familiar with PROC SQL.
delete from YourTableName where DATEDIFF(dd,Date_Announced