Link to home
Start Free TrialLog in
Avatar of hubfub
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?
Avatar of RiteshShah
RiteshShah
Flag of India image

you can do something like:

delete from YourTableName where DATEDIFF(dd,Date_Announced,[date])>=205
ASKER CERTIFIED SOLUTION
Avatar of RiteshShah
RiteshShah
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hubfub
hubfub

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 a date function built in in SQL Server, "DD" gives you difference in days.

can't you even run below command?



select DATEDIFF(dd,getdate()-250,getdate())

Open in new window

Avatar of hubfub

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?
those command should run in SQL Server, not familiar with PROC SQL.