Vinit Patel

Find the Record Between Two dates From SQL SERVER 2005. & The Date Format is different in server & application

Posted on: June 30, 2009


set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

go

ALTER PROCEDURE [dbo].[GetEmpBookIssueDetail]

@DeptExamBookIssueID int,

@FromDate varchar(100)=null,

@ToDate varchar(100)=null

AS

BEGIN

Declare @FDate Datetime

Declare @TDate Datetime

if @FromDate is not null

Begin

Exec GetDateByDate @FromDate=@FromDate,@Date=@FDate output

ENd

if @ToDate is not null

Begin

Exec GetDateByDate @FromDate=@ToDate,@Date=@TDate output

ENd

SELECT dd.DeptExamBookIssueID,dd.EmployeeName,dd.Designation,dd.BookCode,b.BookTitle,b.Price,

Convert(varchar,dd.IssueDate,103) as IssueDate,

Convert(varchar,dd.ReturnDate,103) as ReturnDate

FROM DeptExamBookIssueDetails dd

LEFT JOIN DeptExamPaper de ON de.DeptExamPaperID = dd.DeptExamPaperID

LEFT JOIN Books b ON dd.BookCode = b.BookCode

WHERE dd.SoftStatus = 0

AND dd.DeptExamBookIssueID = @DeptExamBookIssueID

OR

(

(

Convert(char(10),IssueDate,101)>=Convert(char(10),@FDate,101) AND

Convert(char(10),IssueDate,101)<=Convert(char(10),@TDate,101)

)

Or

(

Convert(char(10),ReturnDate,101)>=Convert(char(10),@FDate,101)

AND Convert(char(10),ReturnDate,101)<=Convert(char(10),@TDate,101)

)

)

ORDER BY DeptExamBookIssueID DESC

END

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Calendar

June 2009
M T W T F S S
    Jul »
1234567
891011121314
15161718192021
22232425262728
2930  

Stats Of Blog

  • 6,962 hits

Cluster Map

%d bloggers like this: