Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find missing dates in a series

Status
Not open for further replies.

asimasm

Programmer
Nov 27, 2000
62
AU
How can i find missing date vaues in a range from a table
for example if the following values are stored in a table
20-02-2002
21-02-2002
24-02-2002
26-02-2002
and if we find the missing values then the result should be
22-02-2002
23-02-2002
25-02-2002
 
Hi.
I've never needed some solution for this situation and I don't know if this is possible with a simgle query. If you don't get it, I suggest two ways:

1. Use a datetime variable within a "while" loop and test each date with a "not exists" row in the table.

2. Create a #Dates table and fill it with all the dates of the needed period. Then execute a "left outer join Table" with a "where Table.Date is null".

Hope this helps you.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top