﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION [dbo].[XConvertDateK]
(
	-- Add the parameters for the function here
	@date AS VARCHAR(50)
)
RETURNS VARCHAR(50)
	AS 
	BEGIN 
	DECLARE @OutDate datetime2
	SET @OutDate = CASE WHEN CHARINDEX('오후',@date)>0 and CHARINDEX('오후 12',@date)<=0 THEN 
	DATEADD(HH,12,CONVERT (DATETIME, REPLACE(@date,'오후',''))) 
	WHEN CHARINDEX('오전 12',@date)>0 THEN 
	DATEADD(HH,-12,CONVERT (DATETIME, REPLACE(@date,'오전',''))) 
	ELSE CONVERT (DATETIME,REPLACE(REPLACE(@date,'오전',''),'오후','') )
	END 
	RETURN @OutDate 
	END
GO


