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)
 comparing datetime with a field in db.

Author  Topic 

takkie
Starting Member

1 Post

Posted - 2004-09-01 : 00:35:05
hello,

i am running this within access (so i think it should be ansi?) Need some help on 2 queries...

question 1,

UPDATE history SET Last_User_Updated = 'TESTING' where Last_updated = '8/30/2004 4:06:36 PM'

Last_Updated is a date time field and I know for sure there is a record with that date time in it, and it should retrieve one row...but i always get an error message saying type mismatch...


question 2.

select email from user where name = 'john'

I always get a 'error syntax near FROM' when I run it. When I change the table user to userinfo, then it works...is it b/c the table USER is a reserve name or something, but then it allowed me to create that table...

Again, this is being run within ACCESS, i am not sure if it suppose to matter...but i am stuck on those... :(

-t

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-09-01 : 00:52:10
Q1: You need to surround your date in # for Access to recognise it.
Q2: Try surrounding the table and/or field names in square brackets. This will specify that it's a table/field name
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2004-09-01 : 01:59:13
Sorry to beat an old drum - but you should also watch your date time format - Access will attempt to implicitly convert the datetime string '8/30/2004 4:06:36 PM' using your control panel regional settings, and who knows what other method. To be strictly correct you really should be explicit about the datetime conversion, and use something like the ISO standard or a 3 letter month code eg
'30 Aug 2004 04:06:36 PM'

Especially for us australians for whom 2/4/2004 means the second day of April and not the 4th day of Feb...



--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page
   

- Advertisement -