Hey everyone,I'm new to SQL Server and all that (coming from a PHP MySQL background) and I'm trying to get an IF statement for what will execute one of two possible queries. Here's what I'm kinda trying to do:ALTER PROCEDURE coglej.GetEventsForDate@eventdate datetime,@eventowner varchar (50)AS IF eventdate is more than 2 weeks awaySELECT dbo.events.event_date, dbo.locations.city, dbo.locations.state, dbo.locations.name, dbo.locations.address1, dbo.locations.address2, dbo.locations.zip, dbo.skus.sku_id, dbo.skus.event_type, dbo.skus.price, dbo.skus.slots_availableFROM dbo.events INNER JOIN dbo.locations ON dbo.events.location_id = dbo.locations.location_id INNER JOIN dbo.skus ON dbo.events.sku_id = dbo.skus.sku_idWHERE (dbo.events.event_date = 'eventdate') AND (dbo.skus.owner = 'eventowner') AND (dbo.skus.price_type = 'Early')ELSE evendate is less than 2 weeks awaySELECT dbo.events.event_date, dbo.locations.city, dbo.locations.state, dbo.locations.name, dbo.locations.address1, dbo.locations.address2, dbo.locations.zip, dbo.skus.sku_id, dbo.skus.event_type, dbo.skus.price, dbo.skus.slots_availableFROM dbo.events INNER JOIN dbo.locations ON dbo.events.location_id = dbo.locations.location_id INNER JOIN dbo.skus ON dbo.events.sku_id = dbo.skus.sku_idWHERE (dbo.events.event_date = 'eventdate') AND (dbo.skus.owner = 'eventowner') AND (dbo.skus.price_type = 'Regular')
That's what I'm trying to in a nutshell. Where I'm running into trouble is finding out if there's a way to compare the dates relative to the 2 week timeframe. Is this something you could do with the DATEADD function?Thanks,Joel