5

I have create a function in Snowflake with two 'date'arguments:

CREATE OR REPLACE FUNCTION "fn_CreateHourLabels"(start_date date,end_date date)
    RETURNS TABLE ...

When I attempt to use the function:

SELECT * FROM TABLE("fn_CreateHourLabels"('2021-03-01','2021-03-11'))

I get the following error: SQL compilation error: error line 1 at position 20 Invalid argument types for function '"fn_CreateHourLabels"': (VARCHAR(10), VARCHAR(10))

I am assuming there is something simple I have missed. Is it because the I have declared the arguments as 'date' data types and the select statement is classifying my date values as strings?

Thanks in advance

1 Answer 1

4

Instead of

SELECT * 
FROM TABLE("fn_CreateHourLabels"('2021-03-01','2021-03-11'))

Call it like this, making sure that Snowflake recognizes those strings as dates:

SELECT * 
FROM TABLE("fn_CreateHourLabels"('2021-03-01'::date,'2021-03-11'::date))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.