2
Reply

Query of SQL Server

Prasant Jinaga

Prasant Jinaga

Jan 4 2011 8:29 AM
9.6k
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
 

Answers (2)