-
March 31st, 2004, 01:36 PM
#1
Comparing dates in SQL
I have a very annoying problem that probably has a simple answer but I just can't see it. In the Member table in my database is an field DateJoined representing the date a particular member joined. What I want to do is perform an update only to those members that joined after a specific date. My problem is that I can't seem to get the SQL command correct to compare the dates. Here is the full statement I have
Code:
UPDATE Member SET Balance = Balance+550 WHERE (DateJoined > 9/3/2004);
The SQL compiles fine, and it runs without error. The problem is that it updates every record in my table, not just the ones after 9/3/2004. There are records in there with dates from 2003 in there, and in fact only one record is after the date above (the reason I picked it to perform tests with). Is my statement wrong, and if so how should I fix it? (If it's of any consequence i'm using MSAcess).
Thanks in advance, Mike.
-
March 31st, 2004, 02:55 PM
#2
# signs ... Date literals need to be surrounded by # signs ...
-
March 31st, 2004, 03:39 PM
#3
i tried that, but now its updating no rows at all....
-
March 31st, 2004, 03:55 PM
#4
ok, i've sorted it....it was reading the date in a different format to the way I expected. Here (in england) we right dates in the format dd/mm/yy but it was reading it in the format mm/dd/yy. Such a simple problem but it's taken me all night to figure it out!
-
April 1st, 2004, 09:59 AM
#5
you can also use the YYYYMMDD format to forget about date issues.
like :
20030401
-
April 1st, 2004, 06:20 PM
#6
i'll remember that in future, thanks As for now, i've finally got it all working.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|