Hi,
I'm trying to convert a .NET Tick int value to a DateTime format.
For example, 637927152990660008 is 2022-07-06 15:41:39.066
Found the following code that works in SQL Server:-
DECLARE @Ticks bigint
set @Ticks = 637927152990660008 -- 2022-07-06 15:41:39.066
select DATEADD(ms, ((@Ticks - 599266080000000000) -
FLOOR((@Ticks - 599266080000000000) / 864000000000) * 864000000000) / 10000,
DATEADD(d, (@Ticks - 599266080000000000) / 864000000000, '01/01/1900')) +
GETDATE() - GETUTCDATE()
2022-07-06 15:41:39.067
Any idea how to convert this to run in Vertica, was hoping to change DATEADD to TIMESTAMPADD, but it does not like that?
DateTimeTicks is an integer column on the database holding the data that needs converting.
select TIMESTAMPADD (ms, ((DateTimeTicks - 599266080000000000) -
FLOOR((DateTimeTicks - 599266080000000000) / 864000000000) * 864000000000) / 10000,
TIMESTAMPADD (d, (DateTimeTicks - 599266080000000000) / 864000000000, '01/01/1900')) +
GETDATE() - GETUTCDATE()
from TickHistory.futures
where DateTimeTicks = 637927152990660008;
ERROR 3457: Function catalog.timestampadd(unknown, numeric, unknown) does not exist, or permission is denied for catalog.timestampadd(unknown, numeric, unknown)
HINT: No function matches the given name and argument types. Candidates are:
catalog.timestampadd(datepart::varchar, count::int, start‑date::timestamptz)
catalog.timestampadd(datepart::varchar, count::int, start‑date::timestamp)
dbadmin=>
Tim