C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » SQL »

Searching data between two dates by ignoring time values


Posted Date: 09 Dec 2008    Resource Type: Code Snippets    Category: SQL
Author: Ashwin Kumar HMember Level: Silver    
Rating: 1 out of 5Points: 10



Here is a stored procedure that returns records between from date and to date by ignoring their time values. If the from date , to date are not supplied it returns all the values of the table.

CREATE Procedure [dbo].getAllRecordsIgnoringTimevalues
(
@FromDate VARCHAR(25) =NULL,--indicates that the parameter it is optional
@ToDate VARCHAR(25) =NULL --indicates that the parameter it is optional
)
As
Begin


Select *
From
[dbo].tabletosearch

WHERE
AND (CAST(FLOOR(CAST( fromdate AS float)) AS datetime) >= convert(datetime,@FromDate)OR ISNULL(convert(datetime,@FromDate),'')='')
AND (CAST(FLOOR(CAST( todate AS float)) AS datetime) <= convert(datetime,@ToDate) OR ISNULL(convert(datetime,@ToDate),'')='')

END




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
SQL search between two dates  .  Search between two dates  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Getting Coloum name from excel sheet and creating database table Part 2 through c#
Previous Resource: Locking
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use