By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,265 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,265 IT Pros & Developers. It's quick & easy.

Comparing multiple fields in a table

P: 1
I have a table with 3 date fields that for any given record should all be populated with the same date (the fields mean 3 different things, just have the same date)

Is there a function that allows me to determine if all the fields are equal and if not return those records?

Thanks for any help.
Nov 20 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 2,878
try this:

Expand|Select|Wrap|Line Numbers
  2. select * from yourtable
  3. where datediff(dd,firstdatecolumn,seconddatecolumn) + datediff(dd,seconddatecolumn,thirddatecolumn)  <> 0
records will return if one of them have different day part. if your dates have different time part but has the same date part, the above query will treat them equal.

-- CK
Nov 20 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.