﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 7,2000 / T-SQL  / Count Months (periods) on program / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 16:12:40 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Count Months (periods) on program</title><link>http://www.sqlservercentral.com/Forums/Topic571824-8-1.aspx</link><description>Is the data you supplied an actual example of your how data table is structured, or is that just to help explain what you need?  If the latter, how is the data in your tables structured?</description><pubDate>Thu, 18 Sep 2008 09:12:20 GMT</pubDate><dc:creator>Garadin</dc:creator></item><item><title>Count Months (periods) on program</title><link>http://www.sqlservercentral.com/Forums/Topic571824-8-1.aspx</link><description>We have clients that are on a program for a few months, then off, then back on the program again. I need to find out how many months they are on the program and then how long they stay on or stay off (spells on or spells off)For example, if January 2006 is period 1, February is period 2 and until September 2008 is period 33 then if I have a client ID, how many periods is the client on the program and if they are off how many months and for how long. Client 1 on the program Jan 2006 (period 1) through April 2006 (period 4), off the program from May 2006 (period 5) to September 2006 (period 9) but is back on in October 2006 (period 10). So the client is on for periods 1-4 which makes that a spell count of 4, off for 5 spells then back on. Year       Month     Period     On/off    Spells2006	January	1	on	12006	February	2	on	22006	March	3	on	32006	April	4	on	42006	May	5	off	12006	June	6	off	22006	July	7	off	32006	August	8	off	42006	Sep       9	off	52006	October	10	on	1Since there are thousands of clients, is there a way to get this to work in T-SQL 2000? I need to know the period and spells for each client. Thanks</description><pubDate>Thu, 18 Sep 2008 08:34:22 GMT</pubDate><dc:creator>No Idea</dc:creator></item></channel></rss>