Joined: 04 May 2010
Online Status: Offline
Posts: 18
Topic: BIGINT to DateTime Posted: 15 Jun 2010 at 11:37pm
Hello experts,
I have this function in MS SQL that converts BIGINT to datetime. The problem is that my customer not allows using DB functions as a security policy in the organization.
The solution is to make the conversion in Crystal formula, but I don't know how to translate this MS SQL function to Crystal Formula. Please help.
The function is: ALTER FUNCTION [dbo].[udfTicksToDateTime]
(
@Ticks BIGINT
)
RETURNS DATETIME
AS
BEGIN
DECLARE @Days BIGINT
DECLARE @DaysBefore1753 BIGINT
DECLARE @TimeTicks BIGINT
DECLARE @Seconds BIGINT
SET @Days = @Ticks / CONVERT(BIGINT,864000000000)
SET @DaysBefore1753 = CONVERT(BIGINT,639905)
SET @TimeTicks = @Ticks % CONVERT(BIGINT,864000000000)
SET @Seconds = @TimeTicks / CONVERT(BIGINT,10000000)
RETURN DATEADD(s,@Seconds,DATEADD(d,@Days - @DaysBefore1753,CONVERT(DATETIME,'1/1/1753')))
END
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum