Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Wouter Benoit
Starting Member
23 Posts |
Posted - 2008-01-16 : 04:10:13
|
| Hello,I'm trying to get all the records in my table that have a specific date. But I get no results.The date column has the data type datetime and is stored like, for example, 11/01/2008 14:45:17 (dd/mm/yyyy)So if I want to see al the records with date 11 januari 2008 I tried to do SELECT *FROM MyTableWHERE date = '11/01/2008'I also tried thisSELECT *FROM MyTableWHERE date LIKE '11/01/2008%'But I get no results or no error message.I checked the forum for an answer and found this solutionSelect *from NyTableWhere MyDateColumn >= '20060114' and MyDateColumn < '20060115'but that doesn't work either. Can someone please tell me what I'm doing wrong.Thanks in advanceWouter |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-16 : 04:18:57
|
| Try:-SELECT *FROM MyTableWHERE date >'11 Jan 2008'AND date <'12 Jan 2008' |
 |
|
|
Wouter Benoit
Starting Member
23 Posts |
Posted - 2008-01-16 : 04:23:28
|
| Thats itThanks a lot |
 |
|
|
Wouter Benoit
Starting Member
23 Posts |
Posted - 2008-01-16 : 04:28:24
|
| Thats itThanks a lot |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-16 : 05:40:44
|
quote: Originally posted by visakh16 Try:-SELECT *FROM MyTableWHERE date >'11 Jan 2008'AND date <'12 Jan 2008'
This wont work if language of the server is not ENGLISHThe correct method isSELECT *FROM MyTableWHERE date >='20080111'AND date <'20080112'MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|