Named Query Between Dates DateTime Type

Trying to create a named query for values between two dates. If I have 2 DateTime parameters, can I use them directly with the SQL statement, or do I need to do something to match the datetime type of the MS SQL table?

SELECT t_stamp, val FROM Data
WHERE ( tag_id = :tag_name ) AND ( t_stamp BETWEEN :date_past AND :date_present )

That should work. Are you getting any errors or no data at all? If no data at all, are you sure tag_id and tag_name are's are usually numbers.

It's a custom table. I don't have connection to the database at the moment, I was just curious about the difference between the datatypes

The column type in the database should be datetime2 for best results. If just the datetime column type, it'll work, but you generally have to run the database and gateway in the same time zone, and look out for time zone issues. (Run gateway and DB in UTC for best results with datetime.)