Looking for assistance in retrieving the upcoming Saturday date based on a date field in a table using a Snowflake JavaScript stored procedure. Any suggestions would be greatly appreciated.
Running the following query in the Snowflake console provides the desired result:
SELECT next_day(TO_DATE(MAX(SALE_DATE)),'Saturday') FROM Sales;
However, upon attempting to implement the same logic within a stored procedure, an error is encountered stating "unexpected Saturday."
I have made an attempt to retrieve the upcoming Saturday date based on the maximum date in the table.
var get_cm = "SELECT next_day(TO_DATE(MAX(SALE_DATE)),'Saturday') FROM Sales";
var get_sql= snowflake.createStatement({sqlText:get_cm);
var res_dt = get_sql.execute();
res_dt.next();
var res = res_dt.getColumnValue(1);
return res;