• You've got the function in place, but it's not comparing it to anything. That's why you're getting an error. Assuming you want exactly 30 days ago, you can do this;

    SELECT...

    FROM...

    WHERE NewsTimeBroadCast.DateTimeSystem = dateadd('d',-30,getdate())

    But if you want all the entries from the last 30 days, do something like this:

    SELECT...

    FROM...

    WHERE NewsTimeBroadCast.DateTimeSystem > dateadd('d',-30,getdate())

    Where possible, avoid running functions against columns because that will prevent index use and lead to scans.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning