Genrate date series

Hi all
I have start date and end ate
I need a date column based on this.
startdate
enddate
02/01/11
02/04/11
03/01/11
03/07/11
04/01/11
04/03/11
Like desired output will be
02/01/11
02/02/11
02/03/11
02/04/11
03/01/11
03/02/11
03/03/11
03/04/11
03/05/11
03/06/11
03/07/11
04/01/11
04/02/11
04/03/11
Please help.
Thanks

CREATE FUNCTION fn_dates(@from AS DATETIME, @to AS DATETIME)
  RETURNS @Dates TABLE(dt DATETIME NOT NULL PRIMARY KEY)
AS
BEGIN
  DECLARE @rc AS INT
  SET @rc = 1
  INSERT INTO @Dates VALUES(@from)
  WHILE @from + @rc * 2 - 1 <= @to
  BEGIN
    INSERT INTO @Dates
      SELECT dt + @rc FROM @Dates
    SET @rc = @rc * 2
  END
  INSERT INTO @Dates
    SELECT dt + @rc FROM @Dates
    WHERE dt + @rc <= @to
  RETURN
END
GO
CREATE TABLE #t (st DATE, en DATE)
insert  into #t
select '02/01/11', '02/04/11' union all 
select '03/01/11' ,'03/07/11' union all 
select '04/01/11', '04/03/11'
SELECT dt FROM #t cross apply (select dt from fn_dates(st, en)) as der
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • Is there a way to change the default colors for data series in charts?

    I have tried to find settings for data series colors in the various CSS files but have not found any.

    Did you try:
    OracleBI/web/app/res/s_.../popbin/
    EX:
    line.pcxml Look for <SeriesDefinition ...
    we modified the line width and a few other things. You'll have to modify all the pcxml files for all the chart types you want to customize.

  • SSRS Bar Chart grouping date series into Months, setting scaler start and end ranges

    I've been trying to solve this issue for a few days now without writing a sql script to create a "blank" for all of missing data points so that I get a bar for each month.  I have date series (by day) data points grouped by two items
    that creates a set of bar charts.  EG:  one chart per product in the tablix detail grouped to site level.
    My issue is I would like the start and end of the charts to be the same for all charts and the only way I get it to work is with a chart that continues to show each date on the chart. 
    EG:
    I have the graph start and end points set and scaling by month as I would like but each bar is a day instead of aggregating to a month level.   My issue I hope to find a workaround for is if I go to Category Groups and define the grouping
    to group with a year and month function the series is no longer treated as date data and I cannot control scaling.  It works fine if all months have activity, but I can't figure out how to always have all charts start at "May 2012" in this example. 
    The only start and end point that I've been able to get to work once doing this are integer based, eg normal start would be 1 for each graph, but 1 doesn't equate to the same month from chart to chart.
    I hope SSRS can provide the solution.  I do know I can write a query that creates a ZERO value for each month/product/site but I don't want to leave the client with a query like that to support.
    -cybertosis

    Hi cybertosis,
    If I understand correctly, you want to display all month category label in the X-Axis. You have configure the Scalar Axis, however, it cannot display the requirement format.
    In your case, if we want the specific data format, we can configure Number property to set the corresponding Category data format. Please refer to the following steps:
    Right click the X-Axis, select Horizontal Axis Properties.
    Click Number in the left pane. Click Date option in the Category dialog box.
    Then, select Jan 2000 option.
    Please refer to the following screenshot below:
    If there are any misunderstanding, please feel free to let me know.
    Regards,
    Alisa Tang
    If you have any feedback on our support, please click
    here.
    Alisa Tang
    TechNet Community Support

  • I want data series in Keynote chart to enter one at a time.

    In older version of Keynote, data series can enter one at a time. In version 6.2, seems all series enter at once. Can different series be made to enter one at a time in Keynote 6.2?

    Select the chart
    Inspector > Animate > Build IN > Add an Effect
    choose an effect
    in the Delivery drop down menu select;   By Element in Series

  • Line chart with more than 15 data series - color problem

    Hi all,
    I've built a line chart with 32 data series (user can control, which of them are displayed at a time). For series 16 to 32 I did manipulate the URL in the browser directly, because Application Express does only display parametrs for up to 15 series. This works fine so far except of displaying the colors. For each sieries I defined a different color. 29 of my 32 series are displayed in the desired color. But series 29, 31 and 32 are displayed in a default-color (#0099CC). It seems that this is a SVG-problem. In the SVG-source I find the wrong color. When I export my application, I see the right color.
    Thanks for help,
    Chris

    Hello,
    Which version of APEX are you using?
    Go to your Flash Chart attributes - get into your series (click the icon) in the section of Series Query you'll find the maximum rows.
    Regards,
    Dimitri
    -- http://dgielis.blogspot.com/
    -- http://apex-evangelists.com/
    -- http://apexblogs.info/

  • How to create line hart with variable number of data series

    Hello,
    I am student and I am completely new to Flex programming but
    I need to urgently create an app that should have a variable number
    of data series but of ame type of object.
    eg. Profits for X,Y and Z in in run while just corp X in the
    next instance.
    How can I accomodate for this in the app? can someone point
    me in the right direction I would really greatful as this project
    is really crucial for my coursework to get finished in timely
    manner.
    Thank you

    Hey,
    I'm not really sure what you want, but you should check out:
    http://demo.quietlyscheming.com/ChartSampler/app.html
    Which has a list of different types of charts in Flex and
    will hopefully help. Also check out charting from ILOG, which is
    quite good:
    http://www.ilog.com/products/elixir/

  • How to change colors of individual column bar in the same data series

    in mac numbers, how to change colors of individual column bar in the same data series. The entire column series gets selected in the column bars and cannot select to change colors of specifc bars.

    Hi Kiran,
    no its not possible through Theme editor also ,because these colors are coming from Compiler which u are using.
    Regards,
    Govindu

  • Dynamic Text for data series ?

    Hi, is posible setting dynamic text in data series when use dynamic value ?
    We need show Actual Year value and Last Year value in Label for Series.
    Thank you.

    This is not possible unless you have enhancement pack 1 for visual composer which I think is still in rampup...
    Here is the enhancement noted in the article below.
    Taken from blog:
    Option to dynamically define element titles
    For chart views, form views, table views, HTML views, nested iViews and popup iViews (popup signal), you can now define dynamic titles using the Expression Editor. A new (ellipsis) button to the right of the field in the Configure Element task panel displays the Title Editor dialog box, in which you enter either or define a custom expression.
    /people/judy.kestecher/blog/2008/08/26/whats-new-in-visual-composer--enhancement-package-1-for-sap-netweaver-70

  • Report Builder with multiple data series

    I am not able to figure out how to create a bar chart using
    multiple data series in the Report Builder. I can do it with
    explicit CFML coding but not in the Report Builder. I am running MX
    version 7 with the current (as of 9/1/07) download of the Report
    Builder.
    My table contains visit information by site, with standard
    demographics on each visit (age, race, gender, etc.) I am trying to
    analyze the data by site, for example, race by site.
    I am using an SQL statement to sort and group by site &
    race. I can get a chart of the number of visits for each site or
    the total number of visits by race across all sites. But I can't
    get race by site. The SQL statement looks like this:
    SELECT race, site, COUNT(*) as counter
    FROM visit_info WHERE userid = #session.uid#
    GROUP BY site, race ORDER by site, race
    Every variation I have tried for showing race by site either
    leaves out part of the results or creates a bar chart that has the
    race and site categories as separate entities (White, Black,
    Chinese, Site1, Site2, Site3, etc). I've also tried creating a
    combined variable (site_race) but that doesn't seem to fare any
    better.
    Any help would be appreciated.

    Pop,
    Badunit's example is one possible arrangement that you might have described; that is, one column for X values and several columns for Y values. This is the case when you should respond that you are sharing X-values. With all the data in one table, you can select it all at once, so you don't have the problem with dragging additional series into the chart.
    The Numbers User Guide PDF's first chapter is the place to start getting your bearings - you will learn how to distinguish Header vs. Body rows and columns. It's worth the effort to take another look at it.
    Since you are using a Scatter Chart, it's important not to use a header column for X because X values must be Numeric, as opposed to Text.
    Jerry

  • Add data series to excel chart

    I have an envelope on a chart in Excel.  I would like to add same test data to the chart.  I can open the workbook and get my data on a worksheet, but can't figure out how to add the data series to the chart using ActiveX.

    Here is some vi's that I forgot that I had for excel. In it is one vi in particular called create chart.vi have alook at it. I'm sending you the whole llb. i have not tested them in LV 8 yet.
    hope they help.
    Joe.
    "NOTHING IS EVER EASY"
    Attachments:
    excel.llb ‏2092 KB

  • Showing data series for two charts on one

    Hi
    I need to represent 2 sets of data on one chart. The first is a linebar chart and the second is a scatter chart. This can be done in Excel by adding multiple named data series.
    Is this possible with crystal report 2008.
    Thanks

    I'm a bit late to discussion, but this is I think the most relevant post I could find.
    I have the same problem - displaying multiple data series on the same chart (line chart or scatter by date).  My problem is complicated by the fact that number of series also depend on the data point.
    Essentially I need to plot readout of test in a monitored room where different number of sites maybe tested depending on the room.  So one room might have three data readouts (three sites), and another five (five sites), and when charting by room, one chart will have three series, and another five.  So even considering using overlapping transparent charts, there are issues of conditionally enabling/disabling the whole chart, of determining maximum number of charts (and room might have dozens of test sites) and also displaying appropriate legend(s).
    There must be a better way!
    TIA,
    Andrey.

  • Displaying different data series on drilldown

    I have a bar/line combo chart which displays two data series in bar form and one in line form.
    What I want to be able to do is to only show the bars when drilling down and not the line data series.
    I haven't found a way to do this yet, can anyone help?

    Thanks for the reply.
    I had considered using navigation to go to another chart, but surely if I do this it will go to the same chart wherever I click on the chart, rather than actually drilling down to the next level in the dimension (and thus being different depending on which item I click on) as a normal drilldown should do, unless I have missed something in your explanation?

  • Data Series Missing in the chart.

    Hi ,
    I have included 4 data series in the chart item.
    But its displaying only one data series in the output.
    that is its displaying only the last series. for eg
    i have included Data series1,Data series2,Data series3,Data series4,
    in output its displaying only Data series4.
    what settings i have to make inorder to get all the four data series to be displayed.
    Please Help.
    Thanks
    Tulsi
    Edited by: Thulasi ram on Jun 16, 2008 9:34 AM

    Hi,
    GML File is developed when you are developing your apllication.
    Procedure to Send the GML.
    Click on Model Menu bar in the Tool bar->select Export option
    Then Zip it and send to me
    Regards,
    Govindu

  • How to fill a date series but skip cells

    How do you fill a date series, but skip cells.

    Wayne Contello wrote:
    A1 is the starting date
    A3=A$1+(ROW()-1)/2
    copy cell A3 and paste in A5, 7, 9, etc
    Alternatively,
    A3 = A1+1
    Leave A2 blank
    Select cells A2 and A3 then grab the "fill" handle (the little yellow circle) and drag down to fill in the rest of the column with the pattern of alternating date/blank cells

  • Show only subset of labels from a data series

    I'd like to show only a few labels from a given data series.  I saw some work-arounds posted from 2010 (e.g., add a new series with just the items to be labeled; turn off all labels on original data series).  Was wondering if it's possible to deal with each series-label individually now, thereby avoiding having to add extraneous series to my data.
    Thank you.
    B.

    Thanks, Jerry.  Very curious --- when I hide rows on my original table, those data aren't removed from my chart.  So I built a new chart with new data and hiding rows on this new table does indeed remove those data from the chart.  So something seems to be happening with my original data table.
    But this is actually separate from what I was asking about.  I'd like to keep all the columns in my chart and just have a few labeled.  Was seeking a way to do that without adding a "For Labeling Only" column to my table (Excel let's one deal with column labels individually; figured Numbers might be able to do that, too). Here's how the workaround looks:
    Thanks again for responding.
    -Brian

Maybe you are looking for