|
![]() |
Property | Value |
Name | udf_StringToDateTime |
Schema | dbo |
Function Type | Scalar |
Deterministic | False |
Is Encrypted | False |
Ansi Nulls Status | True |
Quoted Identifier Status | True |
Description |
Name | Type |
Name | Type |
Object | Property | Value |
/****** Object: UserDefinedFunction [dbo].[udf_StringToDateTime] Script Date: 03/09/2017 16:47:10 ******/ SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON CREATE FUNCTION [dbo].[udf_StringToDateTime] ( @DateText VARCHAR(8) ,@TimeText VARCHAR(7) ) RETURNS datetime AS BEGIN DECLARE @TargetDateTimeString VARCHAR(21) DECLARE @ConvertedDateTime datetime SET @TimeText = REPLICATE('0',7-LEN(@TimeText))+CONVERT(VARCHAR,@TimeText) SET @TargetDateTimeString = ( SUBSTRING(@DateText,1,4) + '-' + SUBSTRING(@DateText,5,2) + '-' + SUBSTRING(@DateText,7,2) + ' ' + SUBSTRING(@TimeText,1,2) + ':' + SUBSTRING(@TimeText,3,2) + ':' + SUBSTRING(@TimeText,5,2) + '.' + SUBSTRING(@TimeText,7,1) + '00' ) SET @ConvertedDateTime = cast(@TargetDateTimeString AS DATETIME) RETURN @ConvertedDateTime END |
Powered by BI Documenter |