Hi,
When i'm using the following query the result is displaying when i'm passing @StartDate='1/1/2011' and @EndDate='1/5/2011'
But its not displaying when i'm passing @StartDate='12/25/2010' or any date of previous year
select * from PS_MSI_LETTER_BATCH BATCH
where( convert(varchar(10),CREATED_DATETIME,101) >=convert(varchar(10),@StartDate,101) and convert(varchar(10),CREATED_DATETIME,101) <=convert(varchar(10),@EndDate,101))
But when i'm using the following query Its displaying in both the cases.i.e if i pass the previous year date or this year date.
select * from PS_MSI_LETTER_BATCH
WHERE CREATED_DATETIME BETWEEN '2009-12-31 03:31:25.760' AND '2011-01-05 03:31:25.760'
Could any one help on this???
Thanks,
Prasant

Raju KatarePosted Jan 6, 2011, 7:13 AM
Use the following
select * from PS_MSI_LETTER_BATCH BATCH
where( convert(varchar(10),CREATED_DATETIME,112) >=convert(varchar(10),@StartDate,112) and convert(varchar(10),CREATED_DATETIME,112) <=convert(varchar(10),@EndDate,112))
Nipun TomarPosted Jan 5, 2011, 6:32 AM
simply try
select * from PS_MSI_LETTER_BATCH BATCH
where CREATED_DATETIME >= @StartDate and CREATED_DATETIME <= @EndDate
or
select * from PS_MSI_LETTER_BATCH BATCH
where CREATED_DATETIME BETWEEN @StartDate and @EndDate