Avatar of Ihab
Ihab
 asked on

How the record "nDateTime" in table TB_EVENT_LOG is written?

I have this SQL Database, the record nDateTime in  TB_EVENT_LOG Table is saved in a way that I cant understand, can anyone tell me how it is saved so I can read it-
In the Views -->IBA_Transactions...I cant read all the records clearly "Date-Time"
I attach the database, just unzip and add the ext .bak
Thanks
2014.zip
Microsoft SQL ServerMicrosoft SQL Server 2008

Avatar of undefined
Last Comment
Habib Pourfard

8/22/2022 - Mon
Habib Pourfard

instead of storing datetime values, they are storing seconds since 1970-01-01. as you can see in the view you need to decode it:

SELECT TOP 1000
        [nEventLogIdn] ,
        CONVERT(NVARCHAR(32), DATEADD(s, TB_EVENT_LOG.nDateTime, '1970-01-01'), 111) AS [Date] ,
        CONVERT(NVARCHAR(32), DATEADD(s, TB_EVENT_LOG.nDateTime, '1970-01-01'), 108) AS [Time]
FROM    [BioStar].[dbo].[TB_EVENT_LOG]

Open in new window


I have no idea why they are storing date data as int instead of datetime.
Ihab

ASKER
Thanks Mr. Pour
But I didnt get the idea , Please can you explain more?
Ihab

ASKER
I need to edit a data and time, How I can do this in the SQL Server Management Studio 2008?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
Habib Pourfard

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.