Convert date in common format and compare in SQL 2005
Examples for Converting date in common format and compare in SQL 2005
To compare the dates you can not directly do that. you have to convert it into a common format and then only you can compare it. See below examples.
select * from table
where DateColumn >= CONVERT(varchar, getdate(),112)
and DateColumn < CONVERT(varchar, getdate()+1,112)
select * from tablename
where DateColumn >=
CONVERT(varchar(10), getdate(),101)
and DateColumn <
CONVERT(varchar(10), dateadd(dd, 1, getdate()),101)
SELECT
*
FROM table
WHERE CONVERT(varchar,DateColumn, 112) = CONVERT(varchar,
GetDate(), 112)
By Perry Popularity (1851 Views)