skafinski
skafinski

Reputation: 314

Cast TimeStamp so like could be used

Can somebody please tell me how timestamp can be casted in Firebird in a way it can be later then used in like statement. Line statement will only search in date part of timestamp so i gues it could first cast to date and then to varchar(10).

I got this, but it doesn't work right

SELECT t.createdon
FROM wstaskinstance t
WHERE CAST(CAST (t.createdon AS DATE) AS VARCHAR(10)) LIKE :Date

Upvotes: 0

Views: 143

Answers (2)

Veela
Veela

Reputation: 280

If you want to return all dates of all years use CONTAINING instead. For example if you pass '11-20' as :date parameter, it will return all dates of all years that contains (2001-11-20,2004-11-20, 2015-11-20...).

SELECT t.createdon
FROM wstaskinstance t
WHERE CAST(CAST (t.createdon AS DATE) AS VARCHAR(10)) 
CONTAINING :Date

Upvotes: 1

Evgeny
Evgeny

Reputation: 4010

If I understand you right, you type something in the filter and then set is in :Date parameter. Then your query should be edited like this:

SELECT t.createdon
FROM wstaskinstance t
WHERE CAST(CAST (t.createdon AS DATE) AS VARCHAR(10)) LIKE ('%'||:Date||'%')

Upvotes: 0

Related Questions