Don't convert dates to
varchar
.
It looks like you're trying to ignore the time part, and retrieve all records for a particular date. If you're using Microsoft SQL Server 2008 or higher, you could change the column and the parameter to
the date
type[
^], which doesn't store the time.
Otherwise, you'll need to look for all dates between the start and end of the specified date:
IF @AttndDate Is Null SET @AttndDate = GetUtcDate();
SET @AttndDate = DateAdd(dd, 0, DateDiff(dd, 0, @AttndDate));
SELECT
r.Username AS Username,
r.surname AS Surname,
r.firstname AS Firstname,
u.branch AS Branch,
r.RTime AS ResumptionTime,
r.CTime AS ClosureTime,
DateAdd(dd, 0, DateDiff(dd, 0, r.ATTNDDate)) AS ATTNDATE
FROM
RCORegister r
INNER JOIN UserMgmt u ON r.Username = u.Username
WHERE
r.ATTNDDate >= @AttndDate
And
r.ATTNDDate < DateAdd(day, 1, @AttndDate)
ORDER BY
r.ATTNDDate DESC