<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Getting Missing Date Values in SQL Server</title>
	<atom:link href="http://rmanimaran.wordpress.com/2008/07/04/getting-missing-date-values-in-sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://rmanimaran.wordpress.com/2008/07/04/getting-missing-date-values-in-sql-server/</link>
	<description>Winners don't do different things.They do things Differently.</description>
	<lastBuildDate>Fri, 06 Nov 2009 08:19:48 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bookmarks about Missing</title>
		<link>http://rmanimaran.wordpress.com/2008/07/04/getting-missing-date-values-in-sql-server/#comment-216</link>
		<dc:creator>Bookmarks about Missing</dc:creator>
		<pubDate>Mon, 26 Jan 2009 05:15:03 +0000</pubDate>
		<guid isPermaLink="false">http://rmanimaran.wordpress.com/?p=79#comment-216</guid>
		<description>[...] - bookmarked by 4 members originally found by susannakuenzl on 2008-12-30  Getting Missing Date Values in SQL Server  http://rmanimaran.wordpress.com/2008/07/04/getting-missing-date-values-in-sql-server/ - bookmarked [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8211; bookmarked by 4 members originally found by susannakuenzl on 2008-12-30  Getting Missing Date Values in SQL Server  <a href="http://rmanimaran.wordpress.com/2008/07/04/getting-missing-date-values-in-sql-server/" rel="nofollow">http://rmanimaran.wordpress.com/2008/07/04/getting-missing-date-values-in-sql-server/</a> &#8211; bookmarked [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred Gordy</title>
		<link>http://rmanimaran.wordpress.com/2008/07/04/getting-missing-date-values-in-sql-server/#comment-215</link>
		<dc:creator>Fred Gordy</dc:creator>
		<pubDate>Wed, 17 Dec 2008 02:22:24 +0000</pubDate>
		<guid isPermaLink="false">http://rmanimaran.wordpress.com/?p=79#comment-215</guid>
		<description>We are building a query to count the number of events per hour, per day.  Most days there are hours that do not have any activity and therefore where the query is run the count of activities per hour show up but there are gaps and the query excludes these.  We still want to show the hours that do not have activity and display a zero so that zero value can then be charted.  The query we using looks like this ...

select datepart(Year, dev_time) as Year, 
datepart(Month, dev_time) as Month, 
datepart(Day, dev_time) as Day,
datepart(Hour, dev_time) as Hour,  
count(tdm_msg) as Total_Incoming_Vehicles 
from TCKT_ACT 
where tdm_msg = &#039;4162&#039; and dev_time &gt;= DATEADD(day, - 1, GETDATE())
group by datepart(Year, dev_time) , 
datepart(Month, dev_time) , 
datepart(Day, dev_time),
datepart(Hour, dev_time)
order by datepart(Year, dev_time) asc, 
datepart(Month, dev_time) asc, 
datepart(Day, dev_time) asc,
datepart(Hour, dev_time) asc</description>
		<content:encoded><![CDATA[<p>We are building a query to count the number of events per hour, per day.  Most days there are hours that do not have any activity and therefore where the query is run the count of activities per hour show up but there are gaps and the query excludes these.  We still want to show the hours that do not have activity and display a zero so that zero value can then be charted.  The query we using looks like this &#8230;</p>
<p>select datepart(Year, dev_time) as Year,<br />
datepart(Month, dev_time) as Month,<br />
datepart(Day, dev_time) as Day,<br />
datepart(Hour, dev_time) as Hour,<br />
count(tdm_msg) as Total_Incoming_Vehicles<br />
from TCKT_ACT<br />
where tdm_msg = &#8216;4162&#8242; and dev_time &gt;= DATEADD(day, &#8211; 1, GETDATE())<br />
group by datepart(Year, dev_time) ,<br />
datepart(Month, dev_time) ,<br />
datepart(Day, dev_time),<br />
datepart(Hour, dev_time)<br />
order by datepart(Year, dev_time) asc,<br />
datepart(Month, dev_time) asc,<br />
datepart(Day, dev_time) asc,<br />
datepart(Hour, dev_time) asc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: R Manimaran</title>
		<link>http://rmanimaran.wordpress.com/2008/07/04/getting-missing-date-values-in-sql-server/#comment-178</link>
		<dc:creator>R Manimaran</dc:creator>
		<pubDate>Tue, 08 Jul 2008 15:03:59 +0000</pubDate>
		<guid isPermaLink="false">http://rmanimaran.wordpress.com/?p=79#comment-178</guid>
		<description>For your Question Try like this..
First Create a Function which will return the WeekDate name i..e Sunday, Monday..


Function:

Create Function [dbo].[DayOfWeek](@dtDate Datetime)
Returns Varchar(10)
AS
Begin
	Declare @rtDayofWeek varchar(10)
	Declare @weekDay INT
	Set @WeekDay=((DatePart(dw,@dtDate)+@@DateFIRST-7)%7)
	Select @rtDayofWeek=Case @weekDay
						when 0 then &#039;Saturday&#039;
						WHEN 1 THEN &#039;Sunday&#039;
						WHEN 2 THEN &#039;Monday&#039;
						WHEN 3 THEN &#039;Tuesday&#039;
						WHEN 4 THEN &#039;Wednesday&#039;
						WHEN 5 Then &#039;Thursday&#039;
						when 6 Then &#039;Friday&#039;
						
End
return(@rtDayofWeek)
End


Create a Temp Table with Column
EntryDate DateTime
DayName Varchar(12)

Populate the Table with date values as follows
Declare @day_index datetime
Select @day_index=&#039;1-Jan-2008&#039;
Declare @index int
select @index=1
while @index &lt; 365
begin
	insert into dbo.TempDatetbl 
		Select @day_index, dbo.DayOfWeek(@day_index)
	SELECT @day_index=DATEADD(day, 1, @day_index)
Select @index=@index+1
end

The above statements will insert the date values and corresponding day value.

Normalize your IOData table to contain id,Entrydate,gatename

Create a Table for Employee as id and name as Columns

Now Query using the all the three tables to get the output(Emp Table,IOData Table and TempDatetbl)</description>
		<content:encoded><![CDATA[<p>For your Question Try like this..<br />
First Create a Function which will return the WeekDate name i..e Sunday, Monday..</p>
<p>Function:</p>
<p>Create Function [dbo].[DayOfWeek](@dtDate Datetime)<br />
Returns Varchar(10)<br />
AS<br />
Begin<br />
	Declare @rtDayofWeek varchar(10)<br />
	Declare @weekDay INT<br />
	Set @WeekDay=((DatePart(dw,@dtDate)+@@DateFIRST-7)%7)<br />
	Select @rtDayofWeek=Case @weekDay<br />
						when 0 then &#8216;Saturday&#8217;<br />
						WHEN 1 THEN &#8216;Sunday&#8217;<br />
						WHEN 2 THEN &#8216;Monday&#8217;<br />
						WHEN 3 THEN &#8216;Tuesday&#8217;<br />
						WHEN 4 THEN &#8216;Wednesday&#8217;<br />
						WHEN 5 Then &#8216;Thursday&#8217;<br />
						when 6 Then &#8216;Friday&#8217;</p>
<p>End<br />
return(@rtDayofWeek)<br />
End</p>
<p>Create a Temp Table with Column<br />
EntryDate DateTime<br />
DayName Varchar(12)</p>
<p>Populate the Table with date values as follows<br />
Declare @day_index datetime<br />
Select @day_index=&#8217;1-Jan-2008&#8242;<br />
Declare @index int<br />
select @index=1<br />
while @index &lt; 365<br />
begin<br />
	insert into dbo.TempDatetbl<br />
		Select @day_index, dbo.DayOfWeek(@day_index)<br />
	SELECT @day_index=DATEADD(day, 1, @day_index)<br />
Select @index=@index+1<br />
end</p>
<p>The above statements will insert the date values and corresponding day value.</p>
<p>Normalize your IOData table to contain id,Entrydate,gatename</p>
<p>Create a Table for Employee as id and name as Columns</p>
<p>Now Query using the all the three tables to get the output(Emp Table,IOData Table and TempDatetbl)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: R Manimaran</title>
		<link>http://rmanimaran.wordpress.com/2008/07/04/getting-missing-date-values-in-sql-server/#comment-176</link>
		<dc:creator>R Manimaran</dc:creator>
		<pubDate>Tue, 08 Jul 2008 12:14:39 +0000</pubDate>
		<guid isPermaLink="false">http://rmanimaran.wordpress.com/?p=79#comment-176</guid>
		<description>I think your table is not a normalized one. Is there any separate table for Employees.. If yes, then IOData table should not contain name in it. just a reference to id in the employee table.
After that you can easily get the required result.</description>
		<content:encoded><![CDATA[<p>I think your table is not a normalized one. Is there any separate table for Employees.. If yes, then IOData table should not contain name in it. just a reference to id in the employee table.<br />
After that you can easily get the required result.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sarika</title>
		<link>http://rmanimaran.wordpress.com/2008/07/04/getting-missing-date-values-in-sql-server/#comment-175</link>
		<dc:creator>sarika</dc:creator>
		<pubDate>Tue, 08 Jul 2008 04:37:34 +0000</pubDate>
		<guid isPermaLink="false">http://rmanimaran.wordpress.com/?p=79#comment-175</guid>
		<description>hi

   i have a problem.
i have a table named IOData.Fields are
name ,id,date ,gatename.
i have to find absent  names,dates excluding weekends for all employees for a month group by name.    anyone pls help me


regards 
sarika</description>
		<content:encoded><![CDATA[<p>hi</p>
<p>   i have a problem.<br />
i have a table named IOData.Fields are<br />
name ,id,date ,gatename.<br />
i have to find absent  names,dates excluding weekends for all employees for a month group by name.    anyone pls help me</p>
<p>regards<br />
sarika</p>
]]></content:encoded>
	</item>
</channel>
</rss>
