April 10, 2008 at 1:31 am
Hi, I have this one syntax which uses more than one 'Or' operators, joining all the phrases composed of two statement in a bracket, where all of these statements having an 'And' in it. The statement I'm trying to use is purposed to retrieve the modified date(if there are any), by comparing them with the one stated in my statement. As you can see it as follows;
Select ArticleTable.Name, ArticleTable.ModifiedDate from ArticleTable where (ArticleTable.Name = '210308-F1-Juara' And ArticleTable.ModifiedDate <> '3/20/2008 9:51:30 PM') Or (ArticleTable.Name = '210308-NSS-LANGGARLARI_702383' And ArticleTable.ModifiedDate <> '3/20/2008 10:03:06 PM') Or (ArticleTable.Name = '210308-phg-fuziah-mpk-2ND' And ArticleTable.ModifiedDate <> '3/20/2008 8:13:10 PM') Or (ArticleTable.Name = '210308-PRA-tsunamisusul-LEAD' And ArticleTable.ModifiedDate <> '3/20/2008 8:02:53 PM')
will return the same article with the other dates not stated in the query, together WITH the same date. I don't know why, I've tried run this in the SQL Server 2000 and the result includes the article with the same date, as if I've wrote:
'ArticleTable.Name = '210308-F1-Juara' And ArticleTable.ModifiedDate = '3/20/2008 9:51:30 PM'
in the statement. What's the different between the '=' and '<>' symbols in MS SQL Server 2000? Are there any other symbols that represents 'Not Equal' or maybe I want it more clear, 'Less than' or 'Greater Than' in SQL server?
April 10, 2008 at 6:42 am
Remember that 'datetime' stores time out to the milliseconds...
'mm'dd'yyyy hh:mm:ss.###'
Your comparison datetime is only showing seconds...'3/20/2008 9:51:30'.
Check your data to see if your datetime column values have a millisecond component that is non-zero. This would cause your problem.
Rather than use 'not equal' you should use 'greater than' or 'less than' your comparison datetime.
If it was easy, everybody would be doing it!;)
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply