Are you still using the Asp. Net control or server-side statement processing to generate a calendar table?
Or are you still using the client segment javascript to generate a calendar table?
Are the tables they generated ranked first on Sunday?
See my generated:
January February
January June
January July
Only a simple SQL statement (Stored Procedure) is used to input the time and output the calendar table with the first column of Monday.
From this point of view, will everyone worry about the week on the C # background?
O (∩) O Haha ~
In fact, there is nothing, is a small storage process, is not the T-SQL well, Daniel don't shoot bricks.
However, it is practical for shrimps. I posted my homepage. I have a thick face and I can't beat any bricks. If you don't believe it, try it ~
The stored procedure is pasted as follows:
Code
-- ===================================================== ======
-- Author: chf
-- Create date: 2009-06-25
-- Description: The input time. The current month list is returned.
-- ===================================================== ======
Alter PROCEDURE GetMonthTable
(
@ Date datetime
)
AS
BEGIN
DECLARE @ Start DATETIME, @ End DATETIME
DECLARE @ Index INT
SET @ Start = DATEADD (MONTH, DATEDIFF (MONTH, 0, @ Date), 0)
SET @ End = DATEADD (MONTH, 1, @ Start)
SET @ Index = DATEDIFF (DAY,-1, @ Start) % 7-1;
SET @ Start = DATEADD (mm, DATEDIFF (mm, 0, @ Date), 0)
SET @ End = DATEADD (mm, 1, @ Start)-1
SET @ Index = DATEDIFF (day, 0, @ Start) % 7
; WITH temp (date, row, col)
(
SELECT date = 1, row = @ Index/7 + 1, col = @ Index % 7 + 1
UNION ALL
SELECT date = date + 1, row = (@ Index + date)/7 + 1, col = (@ Index + date) % 7 + 1
FROM temp
WHERE date <= DATEDIFF (DAY, @ Start, @ End)
)
Select isnull (CONVERT (CHAR (2), [1]), '') AS 1,
ISNULL (CONVERT (CHAR (2), [2]), '') AS 2,
ISNULL (CONVERT (CHAR (2), [3]), '') AS 3,
ISNULL (CONVERT (CHAR (2), [4]), '') AS 4,
ISNULL (CONVERT (CHAR (2), [5]), '') AS five,
ISNULL (CONVERT (CHAR (2), [6]), '') AS 6,
ISNULL (CONVERT (CHAR (2), [7]), '') AS day
FROM temp
Bytes
(
MAX (date) FOR col IN ([1], [2], [3], [4], [5], [6], [7])
) AS B
END
GO