Selecting Records in SQL database with DATE

I am getting the following “ERROR: Conversion failed when converting date and/or time from character string.” when I attempt to select records from SQLExpress database based on the date. Specifically, I only want records that were added in the last 24 hours.

I know I am missing something basic, but I haven’t determined a solution. My report seems to be displaying the entire database that began in July 2015 which is thousands of records if I am not selecting by date.

StartDate and EndDate are both Date type and .Time_Stamp is also a datetime format in the database.

EDIT: Although I should be asking what version of Ignition.

Try putting in question marks and put the parameters below.

1 Like

I will try that. I went to an SQL function:

[Interval].Time_Stamp between (select dateadd(hour, -24, getdate())) and (select dateadd(hour, +0, getdate()));

that seems to work though…I’m interested in trying your solution.

It does work as well! The ? for the parameters is new to me. I haven’t used the parameters in my report queries before. Thanks!

1 Like