Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sql dates

Author  Topic 

fmardani
Constraint Violating Yak Guru

433 Posts

Posted - 2004-07-22 : 04:12:06
HI,
There is a folder on the network that has about 300 subfolders. These subfolders are dates going back to last year.
There is supposed to be one file (date) per day except sundays.
I have run a program which inserted these dates into a table.
So now I have the name of these subfolders (dates) in a table.
The question is, how can I find out which days are missing from this list except sundays.
Remember, there should be a file per day.
Thanks

Kristen
Test

22859 Posts

Posted - 2004-07-22 : 04:49:35
[code]
SELECT *
FROM MyTable T1
WHERE DATEDIFF(Day,
(
-- Most recent preceeding day
SELECT MAX(T2.MyDate)
FROM MyTable T2
WHERE T2.MyDate < CASE WHEN DATEPART(WeekDay, T1.MyDate) = 2
-- If testing against a Monday then base on Sunday
THEN DATEADD(Day, -1, T1.MyDate)
ELSE T1.MyDate
END
), T1.MyDate) > 1 - More than 1 day difference?
[/code]
Kristen
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2004-07-22 : 06:15:37
you genius
:o)
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-07-22 : 06:52:23
<fx:looks over shoulder>
Go to Top of Page
   

- Advertisement -