Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
SQL: Filter between dates using a stored procedure
Author:
Syed Irtaza Ali
E-mail:
Click to e-mail author
Website:
http://www.edreamz.net
Submitted:
2/14/2005
Version:
VB.NET 2003
Compatibility:
VB.NET 2003
Category:
Databases
Views:
24431
SQL Server: Filter between dates using a stored procedure. This procedure lets you filter between dates using a date criteria.
Declarations:
exec usp_psPeriodExist '01/31/2005 06:50PM','~' exec usp_psPeriodExist '01/31/2005 21:50','~' exec usp_psPeriodExist '01/31/2005 23:59:59.998','~'
Code:
Create procedure usp_psPeriodExist ( @sSearchDate datetime, @sActiveInd varchar ) as begin declare @sMySQL as nvarchar(2500) set @sMySQL = ' select PERIOD_ID, BEGIN_PERIOD, END_PERIOD, ACTIVE_RECORD from PERIOD where 1=1 ' set @sMySQL = @sMySQL + ' AND (''' + cast(@sSearchDate as varchar) + ''' between BEGIN_PERIOD and END_PERIOD) if (@sActiveInd <> '~') begin set @sMySQL = @sMySQL + ' and ACTIVE_RECORD = ''' + cast (@sActiveInd as varchar) + '''' end exec sp_executeSQL @sMySQL end
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement