Tuesday, August 26, 2008

cast dateTime in the data base to Same Format And Compare Two days acordingly

SELECT * FROM dbo.tblCourse where convert(varchar(12), [ExpireDate],102)=convert(varchar(12), getdate(),102)


//Example 2

SELECT UserId,Email,firstName,tblCourse.CourseTitle FROM tblUsers INNER JOIN tblCourse
ON tblUsers.UserId = tblCourse.CreatedBy
WHERE UserId IN (SELECT DISTINCT CreatedBy
FROM dbo.tblCourse)
AND convert(varchar(12), [ExpireDate],102)=convert(varchar(12), getdate(),102)

No comments: