Solved

Compare the Date and Time of the same column in the same table

Posted on 2015-01-13
4
85 Views
Last Modified: 2015-01-27
I need to find multiple occurrences of the exact date and time in the same "create date" column in the same table. We had an issue where a return authorization record was created on the same date and at exactly the same time, it had the same address but different names and serial numbers, I am trying to determine if there are any more that may have occurred and put some preventives measures in place to catch this.     Exact Date and Time
0
Comment
Question by:skull52
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 40547036
To find the duplicates...

SELECT DateCreated, COUNT(1) AS Cnt
FROM YourTable
GROUP BY DateCreated
HAVING COUNT(1) > 1

Open in new window

0
 
LVL 5

Expert Comment

by:MohitPandit
ID: 40547054
To fetch:

SELECT
	*
FROM YourTable
WHERE DateCreated IN
(
	SELECT DateCreated
	FROM YourTable
	GROUP BY DateCreated
	HAVING COUNT(1) > 1
)
ORDER BY DateCreated

Open in new window

0
 

Author Comment

by:skull52
ID: 40547063
Thanks for the quick response Patrick, but your query is giving me results that may not be accurate, for example  2013-07-29 10:45:04.000 shows 19 occurrences for that date and time this may because I also need to match other columns, such as address state and Zip.
0
 

Author Comment

by:skull52
ID: 40547098
OK, so... the reason I got so many occurrences, which is accurate , is that  that if the customer is returning multiple items it generates a RA number for each and uses the same time stamp.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question