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 |
|
xaphod
Starting Member
4 Posts |
Posted - 2004-04-13 : 05:33:09
|
Hi,Im trying to select data based on date. When I do a "select * from dates" I get the Date: 2004-03-03 00:00:00. But when I try to "select * from dates where Date= 2004-03-03 00:00:00" I get a Conflict-in-types-error"What is wrong??Plz help /xaphod  |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-04-13 : 05:58:16
|
| Put the date literal between single quotes.select * from dates where Date = '2004-03-03 00:00:00'Duane. |
 |
|
|
xaphod
Starting Member
4 Posts |
Posted - 2004-04-13 : 06:58:52
|
| Hi Duane,Thats not working!!EDIT:It's working if i change the datatype in DB to Text (Access)But can't I have date as datatype??? |
 |
|
|
Amethystium
Aged Yak Warrior
701 Posts |
Posted - 2004-04-13 : 07:03:54
|
| Please post the code + error message you get.________________Make love not war! |
 |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-04-13 : 07:46:22
|
| Sorry I am not very familiar with Access I assumed that you were using SQL Server.You should have posted this in the Access forum then. Not this one.Duane. |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2004-04-13 : 08:57:22
|
| For access wrap the 'date' with '#'s...drop the 'hh:mm:ss' bit as well... |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
xaphod
Starting Member
4 Posts |
Posted - 2004-04-13 : 09:46:01
|
Sorry Duane, if I posted this in wrong forum.Andrew, I dont understand your example, what do you mean with "wrap the 'date' with '#'s..."?? My SQLCommand is: dim oCmd as new OleDbDataAdapter("select * from myDates WHERE Date = 2004-03-03 order by Date" , oConn)The datatype in Access is Date/Time. I have a post in DB where Date='2004-03-03', I can execute the above command with no errors, but I don't get a single row back!I've also tried to set Date='2004-03-03 01:01:01' and execute "select * from myDates WHERE Date = 2004-03-03 01:01:01 order by Date"then I get the error:Syntaxerror(operator missig) in query 'Date = 2004-03-03 01:01:01'. Anybody have a clue?EDIT: Great Brett!! That solved it!! Best regards to all /xaphod |
 |
|
|
|
|
|