DECLARE @APPS_ID NVARCHAR(3)
,@COMP_CODE NVARCHAR(8)
,@ORDER_DATE NVARCHAR(10)
SET @APPS_ID = 'S01' -- SESSION 값을 사용
SET @COMP_CODE = 'S002' -- SESSION 값을 사용
-- 마감시간으로 주문일자 구하기
SELECT
@ORDER_DATE =
CASE
WHEN CONVERT(NVARCHAR(5), GETDATE(), 114) < S.CODE_REF1
THEN GETDATE()
ELSE DATEADD(D, 1, GETDATE())
END
FROM
BAS_COMPANY C
INNER JOIN BAS_SUBCODE S WITH(NOLOCK)
ON C.APPS_ID = S.APPS_ID
AND S.MAIN_CODE = 'B002'
AND C.CLOSING_TIME = S.SUB_CODE
WHERE
C.APPS_ID = @APPS_ID
AND C.COMP_CODE = @COMP_CODE
-- 주문 날짜만 가져오기
SELECT
--@order_date order_date
CONVERT(NVARCHAR(10), @order_date, 112) order_date