After listing sql calendar date values in a month as rows, we need to display them now in a format similar to frequently used in printed calendars.
The day names are listed as column names and dates are shown under the related columns.
The first solution is supplied by Plamen Ratchev from SQLStudio.com using the t-sql PIVOT. Since I liked the t-sql code he coded much I want to share it with you here.
And the output of this sql pivot statement will return the following result set as output which is displaying sql dates in a calendar format.
The day names are listed as column names and dates are shown under the related columns.
The first solution is supplied by Plamen Ratchev from SQLStudio.com using the t-sql PIVOT. Since I liked the t-sql code he coded much I want to share it with you here.
SELECT
[Sunday],
[Monday],
[Tuesday],
[Wednesday],
[Thursday],
[Friday],
[Saturday]
FROM
(
SELECT
DATEPART(WEEK, [date]) AS week_number,
[date],
[days]
FROM dbo.getFullmonth('20080229')
) AS Dates
PIVOT
(
MIN([date])
FOR
[days] IN (
[Sunday],
[Monday],
[Tuesday],
[Wednesday],
[Thursday],
[Friday],
[Saturday]
)
) AS Pivots
Thank you so much for sharing this great blog.Very inspiring and helpful too.
ReplyDeleteLoadRunner Training in Chennai
Loadrunner Training
Loadrunner Training in Velachery
QTP Training in Chennai
UFT Training in Chennai
clinical sas training in chennai
SAS Course in Chennai
LoadRunner Training in Chennai
Very Good Blog. Highly valuable information have been shared. Highly useful blog..Great information has been shared. We expect many more blogs from the author. Special thanks for sharing.
ReplyDeleteMicrosoft Windows Azure Training | Online Course | Certification in chennai | Microsoft Windows Azure Training | Online Course | Certification in bangalore | Microsoft Windows Azure Training | Online Course | Certification in hyderabad | Microsoft Windows Azure Training | Online Course | Certification in pune