 				SumA_doc, SumB_doc  
 				)
 			
-			values	(convert(char(10),@toDate-1,120), @text, @file, @conf, @html,
+			values	(convert(char(10),getdate(),120), @text, @file, @conf, @html,
 				 @chat, @billb, @url, @browser, @chart,
 				 @SumA_doc, @SumB_doc  
 				)

declare @text int, @file int, @conf int, @html int, @chat int, @billb int, @url int, @browser int, @chart int
declare @textLast int, @fileLast int, @confLast int, @htmlLast int, @chatLast int, @billbLast int, @urlLast int, @browsLast int, @chartLast int
declare @SumA_doc int, @SumB_doc int
declare @toDate datetime, @lastDate datetime

select @toDate = getdate()
--select convert(char(10),@toDate,120)


select @text=count(*) from meta where doc_type = 2 and activate=1

select @file=count(*) from meta where doc_type = 8 and activate=1

select @conf=count(*)from meta where doc_type = 102 and activate=1 

select @html=count(*) from meta where doc_type = 7 and activate=1 

select @chat=count(*)from meta where doc_type = 103 and activate=1 

select @billb=count(*) from meta where doc_type = 104 and activate=1 

select @url=count(*)from meta where doc_type = 5 and activate=1 

select @browser=count(*) from meta where doc_type = 6 and activate=1 

select @chart=count(*) from meta where doc_type = 101 and activate=1 

select @lastDate=max(countDate) from countDoc



create procedure CountDocByType

/* Counts all meta document off every type where meta > 1000 (not help document) and insert the result in table countDoc 
   If all values is the same as last insert no insert will be done except for
   day 28 in month when insert always will be done. 
   This procedure is executed by SQL Server Agent in job "countDoc" every day at 07:00		
