| 123456789101112131415161718192021222324252627282930 |
- SET QUOTED_IDENTIFIER ON
- GO
- SET ANSI_NULLS ON
- GO
- CREATE FUNCTION [dbo].[to_datetime] (@d varchar(255))
- RETURNS datetime
- with execute as CALLER
- AS
- BEGIN
- declare @to_datetime datetime;
- if @d is null
- return null
- if (charindex(' ', @d) = 0)
- set @d = @d + 'T00:00:00';
- else
- set @d = replace(@d, ' ', 'T') + ':00';
-
- if isdate(@d) = 0
- return null
- set @to_datetime = convert(datetime, @d)
- return (@to_datetime);
- END
- GO
- SET QUOTED_IDENTIFIER OFF
- GO
- SET ANSI_NULLS OFF
- GO
- GO
|