MS-SQLでOracleのTO_DATE関数を実装
CREATE FUNCTION [dbo].[TO_DATE]
(
-- Add the parameters for the function here
@piStrDate varchar(512),
@piFORMAT varchar(512)
)
-- =============================================
-- Author:アスカクリエイト
-- Create date: 2011/03/16
-- Description: 文字列をFORMAT文字列で日付型を返す
-- =============================================
RETURNS DateTime
AS
BEGIN
-- Declare the return variable here
DECLARE @vDate AS DateTime
-- 文字8
IF (@piFORMAT IS NULL) OR (UPPER(@piFORMAT) = 'YYYYMMDD')
BEGIN
SET @vDate = CONVERT(datetime, @piStrDate, 112)
END
ELSE
BEGIN
SET @vDate = CONVERT(datetime, @piStrDate, 112)
END
-- Return the result of the function
RETURN @vDate
END
0 件のコメント:
コメントを投稿