As the system is Snowflake, plz leverage the below syntaxes :
@concat('SELECT DATEADD(''day'', 1, TO_DATE(''', variables('v_POLLED_DT'), '''))')
or
SELECT DATEADD('day', 1, TO_DATE(@{variable}))
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm having an issue where I'm trying to add a day to a start date parameter, this is the script I used in the Script activity within ADF:
@concat('SELECT DATEADD(dd, 1, CONVERT(DATETIME, ''',variables('v_POLLED_DT'), '''))')
However I'm getting the following error message:
Failed to execute script. Exception: ''Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Failed to execute the query command during read operation.,Source=Microsoft.DataTransfer.Execution.ScriptActivityExecutor,''Type=Apache.Arrow.Adbc.C.CAdbcDriverImporter+ImportedAdbcException,Message=[Snowflake] 000904 (42000): SQL compilation error: error line 1 at position 30 invalid identifier 'DATETIME',Source=Apache.Arrow.Adbc,''
Am I missing something here, as I'm pretty sure this is a valid T-SQL statement?
As the system is Snowflake, plz leverage the below syntaxes :
@concat('SELECT DATEADD(''day'', 1, TO_DATE(''', variables('v_POLLED_DT'), '''))')
or
SELECT DATEADD('day', 1, TO_DATE(@{variable}))
The error occurs because you're using T-SQL functions (CONVERT
and DATETIME
) which are not supported in Snowflake. Snowflake uses a different SQL dialect, and the function CONVERT(DATETIME, …)
is invalid there.
To add a day to a date in Snowflake, you should use the DATEADD
function with a valid date conversion function like TO_TIMESTAMP
. Here's how you can rewrite your script for the Script activity in Azure Data Factory:
@concat('SELECT DATEADD(DAY, 1, TO_TIMESTAMP(\'', variables('v_POLLED_DT'), '\'))')
Reference:
These functions are the correct way to handle date arithmetic and conversion in Snowflake.
I hope this information helps.
Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.
I managed to fix the issue, it turns out the Until activity works by looping continuously until the condition is met, rather than using variable
less than or equal to EndDate
, I just need to change it to variable
greater than EndDate
and it worked