>Hi John, at sometime I would like to use the % as a wildcard to pickup all dates if when I need to. Also, I have intentionally set lddate to "%". Thanks for your help.
LIKE and % do matching based on strings. This is not going to work with a date field the same as it wouldn't work with a numeric. In fact, you need to consider datetime fields as a kind of numeric. Sometimes they are really awful to work with, especially when you are doing searches on say a last modified field that can have any time component.
The best I can suggest is to change the comparison from a date field to a character field. This may not give you what you want, but you can do this:
SELECT *
FROM dbo.test TEST
WHERE CONVERT(CHAR(20), test.date1, 112) = ?v_date
where v_date has some STRING value that can match the convert string
or
SELECT *
FROM dbo.test TEST
WHERE CONVERT(CHAR(20), test.date1, 112) Like ?v_date
where v_date is also some string date with a % also embedded within.
v_date is your parameter field that is passed to ODBC (where the substitution is made prior to sending the query to SQL Server.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement