Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Table From Start and End Date with Period

Author  Topic 

Kalaiselvan
Posting Yak Master

112 Posts

Posted - 2013-01-23 : 10:01:59
Hi,
Need a Table with single column From the following Input.

Start Date = 01 Jan 2011
End Date = 01 Dec 2012

TABLE FOR PERIOD=MONTHLY
[PERIOD]
JAN 2011
FEB 2011
MAR 2011
APR 2011
MAY 2011
JUN 2011
JUL 2011
AUG 2011
SEP 2011
OCT 2011
NOV 2011
DEC 2011
JAN 2012
FEB 2012
MAR 2012
APR 2012
MAY 2012
JUN 2012
JUL 2012
AUG 2012
SEP 2012
OCT 2012
NOV 2012
DEC 2012


TABLE FROM PERIOD=QUARTER
[PERIOD]
JAN 2011
APR 2011
JUL 2011
OCT 2011
JAN 2012
APR 2012
JUL 2012
OCT 2012


TABLE FROM PERIOD=HALF
[PERIOD]
JAN 2011
JUL 2011
JAN 2012
JUL 2012


TABLE FROM PERIOD=YEARLY
[PERIOD]
JAN 2011
JAN 2012


Depends on Period Chosen Need to Built the Single Column table. Help me to fix this Functionality.


Regards,
Kalai

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2013-01-23 : 10:17:03
You should have a calendar table of dates (F_TABLE_DATE by Michael Valentine Jones, which can be found in the scripts forum here, is very useful), everything else you asked for can be derived from that table. Let the front-end do the formatting.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -