• tigars39 (7/30/2013)


    That column is the tIME STAMP (date and time) that a sample of a reading have been taken. I just genertaed insert statement for the first few rows because that table contains thousand of rows! the values are differents in other rows for the TimeStamp_ID Also as i said, i also found a scalar function part of the database wich is as follow:

    /****** Object: UserDefinedFunction [dbo].[udfTicksToDateTime] Script Date: 07/30/2013 11:43:35 ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    ALTER FUNCTION [dbo].[udfTicksToDateTime]

    (

    @Ticks BIGINT

    )

    RETURNS DATETIME AS

    BEGIN

    DECLARE @DaysBIGINT

    DECLARE @DaysBefore1753BIGINT

    DECLARE @TimeTicksBIGINT

    DECLARE @SecondsBIGINT

    IF @Ticks < CONVERT(BIGINT,624511296000000000)

    BEGIN

    SET @Ticks = CONVERT(BIGINT,624511296000000000)

    END

    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

    i think that is the fucntion used to convert the ticks to datetime. i just dont know how i can use it in my query to convert back to datetime

    When you say TimeStamp what do you mean? Where do those values come from? TimeStamp is a datatype in sql server, I don't think you mean that. I get the impression that is a value that represents something but I have no idea what it is. Maybe it is the number of seconds since 1/1/1900? Give me some idea of what the number means and I can help.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/