I need to get the upcoming saturday based on the date field in table. I need to implement code using snowflake javascript stored procedure. Suggestions appreciated.
When following query is executed using snowflake console, I get result.
SELECT next_day(TO_DATE(MAX(SALE_DATE)),'Saturday') FROM Sales;
But when I implement the same using stored procedure it throws error "unexpected Saturday"
Tried to fetch the upcoming Saturday date based on the maximum date in 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;
2
Answers
This process should work:
I adjusted your JS code slightly and it worked for me: