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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Cant select by Date

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.
Go to Top of Page

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???
Go to Top of Page

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!
Go to Top of Page

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.
Go to Top of Page

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...
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-04-13 : 09:41:28
Date = #2004-03-03 00:00:00#

Or post Access questions here


http://www.sqlteam.com/forums/forum.asp?FORUM_ID=3

Or Here

http://www.dbforums.com/f84/

Or just open QBE in Access...



Brett

8-)
Go to Top of Page

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
Go to Top of Page
   

- Advertisement -