x

Calendar query

Hello every one I am trying to create a query for calendar month in the results window.

My output should be like

sun mon tue wed thu fri sat  
1   2   3   4   5   6   7  
8   9   10  11  12  13  14   
15   16  17  18  19  20  21  
22   23  24  25  26  27  28  
29   30  31  
and it should be working for every month we execute. can anyone plz suggest me some ideas.
more ▼

asked Jul 27, 2012 at 03:52 PM in Default

sumansidda gravatar image

sumansidda
0 1 1 1

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first
A quick search found this solution: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1173&lngWId=5 by the Exceptional DBA himself, Jeff Moden.
more ▼

answered Jul 27, 2012 at 07:53 PM

Kev Riley gravatar image

Kev Riley ♦♦
54.1k 47 49 76

(comments are locked)
10|1200 characters needed characters left
Thank you Thats a really gr8 way to do it. Just was thinking is it possible to do the same thing using a while loop.
more ▼

answered Aug 03, 2012 at 02:58 PM

sumansidda gravatar image

sumansidda
0 1 1 1

I know this is an old post but I still have to ask... why do you want to do it using a WHILE loop?
Dec 01, 2013 at 05:30 AM Jeff Moden
Initially I tried it using some loops and got to a certain point where I couldn't get the exact result I wanted. So just was a bit curious to find out if there is a way to do it using while loop. :)
Dec 02, 2013 at 10:00 AM sumansidda
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x991
x10

asked: Jul 27, 2012 at 03:52 PM

Seen: 3084 times

Last Updated: Dec 02, 2013 at 10:00 AM