-3

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);

Working Example

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.

8
  • 2
    1) DO NOT use images for textual data, copy and paste the examples as text into the question text. 2) Add, as text, the 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. Commented Mar 31 at 18:28
  • I'm guessing you defined your function to accept two ints and the table holds one bigint, one int. Make that a SELECT 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/-F5BVcVW
    – Zegarek
    Commented Mar 31 at 18:28
  • What is wrong with the standard function to_timestamp() ? Commented Mar 31 at 18:31
  • Also change the title of the question, it is not about the passing one function into another. Commented Mar 31 at 18:39
  • 1
    @Zegarek, I approved the edit to get things moving again. Commented Mar 31 at 18:42

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.