I have a function called udf_unixtimestaptodatetime
. based off of the unixtimestamp it will provide the associated date and time. the script works when placing in the unixdatetime (along with other variables required.
Query:
SELECT *
FROM archive.udf_unixtimestamptodatetime(1742985568, 391);
however when i attempt to replace the variables within the function (similar to MSSQL), I receive an error. It will not perform correctly:
Query:
SELECT archive.udf_unixtimestamptodatetime(createddate, lotteryfk)
FROM stage.ticketentry
Will not work when selected like this
In Postgresql, What would be the equivalent of:
Query:
SELECT archive.udf_unixtimestamptodatetime(createddate, lotteryfk)
FROM stage.ticketentry
In other words how do i assign the parameters for the function utilizing the columns from an existing table?
I need to be able to utilize the function to return the date for each column in table.
CREATE FUNCTION ...
statement for the function. 3) The issue is not that you are using are fields from the table, it is that the types don't match the function definition.int
s and the table holds onebigint
, oneint
. Make that aSELECT archive.udf_unixtimestamptodatetime(createddate::int, lotteryfk) FROM stage.ticketentry;
and it should work, as long as the value fits under the integer limit. See this example: dbfiddle.uk/-F5BVcVWto_timestamp()
?