Convert date in common format and compare in SQL 2005 By C-Sharp Guru Printer Friendly Version View My Articles 10 Points |  |
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) |
| Biography |
| I am System Programmer. I would love to do research oriented works on performance, securities and system programming. I am also interested in LINUX Kernel Programming. |
| |
| Article Discussion: Convert date in common format and compare in SQL 2005 |
| C-Sharp Guru posted at 21-Oct-08 09:57 |
| Original Article |
 |
|