I need to get the frist date of the year and the last day of the most recent quarter (eg "1-1-2019 to 9-30-2019" since today is 12/12.19) using SSIS expressions.
I can do this by using SQL statement like this below.
SELECT CONVERT(VARCHAR(10), DATEADD(yy, DATEDIFF(yy,0,getdate()), 0), 101) +' to ' + CONVERT(VARCHAR(10), DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0)), 101) AS QuarterToDate
However, I cannot do this in SSIS Expression Builder. I'm using the following.
CONVERT(VARCHAR(10), DATEADD(yy, DATEDIFF(yy,0,getdate()), 0), 101) +' to ' + CONVERT(VARCHAR(10), DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0)), 101)
But I get the following error message:
Expression cannot be evaluated.
The function "VARCHAR" was not recognized. Either the function name is incorrect or does not exist.
Attempt to parse the expression "CONVERT(VARCHAR(10), DATEADD(yy, DATEDIFF(yy,0,getdate()), 0), 101) +' to ' + CONVERT(VARCHAR(10), DATEADD(dd, -1, DATEADD(qq, DATEDIFF(qq, 0, GETDATE()), 0)), 101)" failed and returned error code 0xC004708A. The expression cannot be parsed. It might contain invalid elements or it might not be well-formed. There may also be an out-of-memory error.