Question
This is what I have so far: CREATE PROCEDURE spDateRange @DateMin varchar = NULL, @DateMax varchar = NULL AS PRINT @DateMin; PRINT @DateMax; IF @DateMin IS NOT NULL AND @DateMax IS NOT NULL BEGIN PRINT @DateMin; IF(ISDATE(@DateMin)=1 AND ISDATE(@DateMax)=1) PRINT 'Valid Date'; ELSE RAISERROR('Parameters not date format', 10, 1); END ELSE RAISERROR ('Invalid parameters', 10, 1); I need to return a result set that includes the InvoiceNumber, InvoiceDate, InvoiceTotal, and Balance for each invoice for which the InvoiceDate is within the date range, sorted with earliest invoice first. And then code a call to the stored procedure created above that returns invoices with an InvoiceDate between April 10 and April 20, 2008. This call should also catch any errors that are raised by the procedure and print the error number and description.
Explanation / Answer
please rate it: CREATE PROCEDURE dbo.spDateRange @DateMin datetime, @DateMax datetime AS begin --PRINT @DateMin IF ( @DateMin IS NOT NULL AND @DateMax IS NOT NULL ) select InvoiceNumber, InvoiceDate, InvoiceTotal, Balance from Invoice where InvoiceDate@DateMin end go