sql server 2008 - Not getting Record Between two dates -


i want rows between 2 dates

here query:

select      distinct convert(varchar(09), [datetime], 103)      studentattendance_fk       lecturerid = 5033 ,      courseid = 1004 ,      subjectid = 120 ,      [datetime] between '3/8/2012' , '3/11/2012' 

format (mm/dd/yyyy)

sample values

3/8/2012 11:40:46 pm 3/8/2012 11:40:46 pm 3/9/2012 11:57:55 3/9/2012 10:48:02 pm 3/10/2012 11:57:20 pm 

the query isn't returning rows between these 2 dates. changes in query?

thanks you

ajay.

if you're using 103 (d/m/y) why clause using m/d/y? using british/canadian regional settings or not? stick standard, unambiguous formats such yyyymmdd , have more predictable results.

select distinct convert(date, [datetime])  dbo.studentattendance_fk lecturerid = 5033 , courseid = 1004 , subjectid = 120 , [datetime] >= '20120308' , [datetime] < '20120312'; 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -