Click here to Skip to main content
11,928,078 members (51,923 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# VB ASP.NET VB.NET
I want to create a Table dynamically according to the Values
I want to show a table

from April Month to March
April  --
May    --
June   --
July   -- 
August -- 
Sept --
Oct -- 
Nov -- 
Dec -- 
Jan -- 
Feb -- 
March --
having two columns one for Month Names and other for Values
Values are calculated on a Formula:
1200/12 for April
1200/11 for May
and like wise divided by descending values and to show them accordingly against the Month Names.
How can I acheive this Please assist
Posted 17-Apr-13 21:28pm
Edited 17-Apr-13 21:54pm
Maciej Los210.1K
Thomas Barbare 18-Apr-13 2:34am
What kind of db do you use ?
OriginalGriff 18-Apr-13 2:34am
What have you tried?
Where are you stuck?
Edo Tzumer 18-Apr-13 3:08am
What kind of table? HTML Table? C# Datatable? Database Table?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you use MS SQL Server, i recommend you to use CTE[^]:

;WITH MyColumns
    SELECT GETDATE() AS CurrMonth, '1200/' AS FirstPart , 12 AS SecondPart
    SELECT DATEADD(mm,1, CurrMonth), FirstPart, SecondPart -1 AS SecondPart
    FROM MyColumns
    WHERE SecondPart>1
SELECT DATENAME(mm, CurrMonth) AS Col1, FirstPart + CASE WHEN LEN(SecondPart)=2 THEN CAST(SecondPart AS NVARCHAR(2)) ELSE '0' + CAST(SecondPart AS NVARCHAR(2)) END AS Col2
FROM MyCOlumns

April		1200/12
May		1200/11
June		1200/10
July		1200/09
August		1200/08
September	1200/07
October		1200/06
November	1200/05
December	1200/04
January		1200/03
February	1200/02
March		1200/01

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100