AnsweredAssumed Answered

Why don't SQL Server date functions work when used as parameters?

Question asked by TehNrd on Aug 15, 2011
Latest reply on Aug 22, 2011 by pete_mccoy1.3055586893899446E12
When I run this type of SQL statement against a MSSQL Server it works perfectly:

SELECT fields FROM DB_Name WHERE DateField >= GETDATE()

Yet when I try to use parameters and pass in a static value of GETDATE() or a process property with a default value of GETDATE() it fails:

SELECT fields FROM DB_Name WHERE DateField >= ?

Errors occurred while building or executing SQL statement: Conversion  failed when converting date and/or time from character string.; Caused  by: Conversion failed when converting date and/or time from character  string.

Is there anyway to make this work using parameters?

If this works when the functions are included directly in the SQL of the database profile I don't see why it shouldn't also work when these values are passed in as parameters.

Thanks,
Jason

Outcomes