특정일 해당 월 주차 구하기 DECLARE @Date DATETIME; SET @Date = GETDATE(); SELECT CEILING((DAY(@Date) + DATEPART(DW, LEFT(CONVERT(VARCHAR(10), @Date, 112), 6) + '01') - 1) / 7.0); 출처: https://icodebroker.tistory.com/2571 [ICODEBROKER] DataBase/SQL Server 2021.01.04
주차정보 구하기 CREATE FUNCTION [mirae].[fn_GetWeekDayInfo] ( @P_indate NVARCHAR(10) -- 검색입력날짜 ) /* SELECT startdate AS WEEK_BEG, enddate AS WEEK_END, weekOfMonth AS WEEK_NUM, weekOfYear AS WEEK_YEAR FROM [mirae].[fn_GetWeekDayInfo]('20211228') */ RETURNS @ReturnTable TABLE ( startdate DATETIME, enddate DATETIME, weekOfMonth INT, weekOfYear INT ) AS BEGIN DECLARE @P_date DATETIME -- 검색일 DECLARE @P_startdate DAT.. DataBase/SQL Server 2021.01.04