in a table having the fields of starttime & endtime ,I want to fetch only the records having starttime & endtime of same days.

select * from tablename where
day(starttime)=day(endtime)
and month(starttime)=month(endtime)
and year(starttime)=year(endtime)

OR

SELECT * from tablename where
CONVERT(VARCHAR(10), starttime, 105) =CONVERT(VARCHAR(10), endtime, 105)

commented: yes , that should work perfectly fine. +8
commented: Good examples! +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.