How to include datetime in a groovy sql query
I am new to groovy scripting, I am attempting to run this simple query, that will return a count which is then used in a compare.
The query is below:
row = sql.firstRow('SELECT count(*) FROM [DB].[dbo].[view] where LastUpdated > \'2016-06-18 03:04:02.550\')
Whenever I run the query it will return the error message below:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script14.groovy: 9: expecting ''', found '\n' @ line 9, column 137. > \'2016-06-18 03:04:02.550\') ^ org.codehaus.groovy.syntax.SyntaxException: expecting ''', found '\n' @ line 9, column
Any ideas as to what I doing wrontg?
- Please see if below link helps:
http://stackoverflow.com/questions/30555790/oracle-sql-date-greater-than-statement I modified the SQL query to do the following:
CONVERT(VARCHAR(23),(DATEADD(month, -2, GETDATE())), 121) instead of actual date value.