dbo.Periodo2Date

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Null on Null Input

False

Schema Bound

False

Assembly

Parameters

2
Name Data Type Length Description
(Result) date 3
@periodo int 4

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
-- =============================================
CREATE OR ALTER FUNCTION dbo.Periodo2Date 
(
 -- Dado un perĂ­odo en dato int convierte a fecha ej: 201708 devuelve 2017-08-01 como objeto DATE

 @periodo         INT
)
RETURNS DATE
AS
BEGIN
 -- Declare the return variable here

 -- Return the result of the function
 RETURN DATEFROMPARTS(CONVERT(INT,@periodo/100), CONVERT(INT, RIGHT(CONVERT(VARCHAR, @periodo), 2)), 01)

END
GO