I am working with a system where date is stored as integer (actual numeric(8,0)) and I have noticed that other systems also store date as int such as cisco in this thread. Example
20120101 -- 01 Jan 2012
Is there any advantage of keeping numeric date system and not using SQL Datetime?
Now I am trying to loop through numeric date to find customers between two dates. If the
enddate encompass two months, I get thousands of records instead of just 60. Example:
create table #temp1(day int,capacity int) /* just a temp table */ declare @start int declare @end int set @start=20111201 set @end = 20120131 while (@start <= @end) Begin insert into #temp1 /* I am storing things in #temp table so data looks pretty */ exec usp_GetDailyCap @date1= @start set @start = @start + 1; end select * from #temp1
This pulls 8931 records instead of 60. Is there a better way to improve the logic above so I pull only valid dates? I tried IsDate and sub-queries but that did not quite work in an efficient way.