I have a datetime dynamic property that is set by an SQL query (dateadd etc). When I try and use this in a button SQL UPDATE I get the following error “Conversion failed when converting datetime from character string.”.
This is the code behind the button :
queryValue =event.source.parent.Correct_start
#queryValue = event.source.parent.getComponent(‘test’).text
Row = event.source.parent.Period
system.db.runUpdateQuery(“UPDATE calendar SET startdate = ‘%s’ where “row number” = %s” % (queryValue, Row), ‘SQLServer’)
If I instead move the # in the above expression to the top line the SQL UPDATE works. The .text it refers to in line 2 gets its date from the exact same SQL query that the dynamic property fails on.