Get Integer to Date
CREATE FUNCTION [dbo].[ufn_utl_GetDateToInteger]
(
@Date DATETIME2
)
RETURNS INTEGER
AS
/*
Author: Mihir Shah
Modified Date: 03/07/2018
Purpose: Function to convert date to integer
Example:
select [dbo].[ufn_GetDateToInteger](StartTime) AS StartTimeInt from [NDISBillCalc].[WorkSegments]
Output:
20180310
20180311
*/
BEGIN
RETURN (CAST(CONVERT(VARCHAR(8), @Date, 112) AS INTEGER));
END;
GO
(
@Date DATETIME2
)
RETURNS INTEGER
AS
/*
Author: Mihir Shah
Modified Date: 03/07/2018
Purpose: Function to convert date to integer
Example:
select [dbo].[ufn_GetDateToInteger](StartTime) AS StartTimeInt from [NDISBillCalc].[WorkSegments]
Output:
20180310
20180311
*/
BEGIN
RETURN (CAST(CONVERT(VARCHAR(8), @Date, 112) AS INTEGER));
END;
GO
Comments
Post a Comment