1
votes

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

1 Answers

0
votes

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