Back to OIM Explorer

dbo.QBM_FCVStringToDatetime

Scalar FunctionSQL_SCALAR_FUNCTIONSandbox DB

Scalar Function.

Source: sandbox-db sys.sql_modules

Source size: 483 characters

Interpretation

  • Database function. Usually supports views, validation, or calculated predicates; look at referenced-by entries for callers.

Relations

  • No extracted relations.

Typed Edges

  • No typed edges extracted for this source.

Complete Source

SQL37 lines
1CREATE FUNCTION dbo.QBM_FCVStringToDatetime(2  @in nvarchar(400)3) RETURNS datetime4  WITH SCHEMABINDING5AS6BEGIN7  DECLARE @erg datetime = NULL8  DECLARE @isDate BIT = 09  SELECT @isDate = isdate(@in)10  IF @isDate = 111  BEGIN12    IF13    RIGHT(@in,14    1) = 'Z'15    BEGIN16      SELECT17        @erg = try_convert(datetime,18        @in,19        127)20    END21    ELSE22    BEGIN23      SELECT24        @erg = try_convert(datetime,25        @in,26        121)27    END28  END29  IF @isDate = 0 OR @erg IS NULL30  BEGIN31    SELECT32      @erg = convert(datetime,33      '1899-12-30',34      121)35  END36  RETURN(@erg)37END
Open raw exported source
SQL ยท Raw5 lines
1     create   function dbo.QBM_FCVStringToDatetime(@in nvarchar(400)) returns datetime with SCHEMABINDING as begin declare @erg datetime = null 2declare @isDate bit = 0 select @isDate = isdate(@in)  if @isDate = 1 begin if right(@in, 1) = 'Z' begin select @erg = try_convert(datetime, @in, 127) end3 else begin select @erg = try_convert(datetime, @in, 121) end end if @isDate = 0 or @erg is null begin select @erg = convert( datetime, '1899-12-30' , 4121) end return (@erg) end 5