ALTER FUNCTION [dbo].[ConvertToClientLocalTime]
(
    -- Add the parameters for the function here
     @Time DATETIME
    ,@TimeZone NVARCHAR(100)
)
RETURNS DATETIME
AS
BEGIN
    -- Declare the return variable here
    DECLARE @LocalDate DATETIME

    SELECT
        @LocalDate =
            CASE WHEN @Time IS NULL OR @Time = '' THEN NULL
                 ELSE dbo.ConvertToClientTime(@Time, @TimeZone)
            END

    -- Return the result of the function
    RETURN @LocalDate;
END
------------------------------Below function called inside above-----
ALTER FUNCTION [dbo].[ConvertToClientTime](@time [datetime], @timeZone [nvarchar](100))
RETURNS [datetime] --WITH EXECUTE AS CALLER
AS
BEGIN
--EXTERNAL NAME [Mmt.Cyramed.Cryptography].[Mmt.Cyramed.Cryptography.Cryptography].[ConvertToClientTime]
RETURN DateAdd(mi,dateDiff(mi, dbo.[GetCompanyUTCDateTime](@time,@timeZone) ,@time ),@time)
END

Comments

Popular posts from this blog

Querying a Data Table Using Select Method and Lambda Expressions in Dot Net

StringToTable

GetPhoneSSNFormat