
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
like operator only valid on string field
trying to limit the extract of data in a Qlik Sense app on an ActivityDate field but I am getting the error "like operator only valid on string field" .. Example of syntax is below
Load
Id,
ActivityDate,
Subject ;
SELECT
Id,
ActivityDate,
Subject
FROM Task
WHERE ActivityDate LIKE '*2017*' OR ActivityDate LIKE '*2018*'
Any help is appreciated.
Thank you,
- dave
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you are writing a SQL SELECT the LIKE operator is dependent on the syntax of the source you are using. It is not following syntax or rules of Qlik Sense.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you are writing a SQL SELECT the LIKE operator is dependent on the syntax of the source you are using. It is not following syntax or rules of Qlik Sense.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I presume the select is against a database and the issue is within the sql and not a Qlik Statement.
- What database is it ?
Does your database field ActivityDate have a data type of date as opposed to a string ?
If you are using Oracle then maybe something like this could suffice :
where extract ( year from ActivityDate ) between 2017 and 2018

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Petter - I was querying a Salesforce database so I had to adhere to the SOQL guidelines. Wound up being CreatedDate > 2017-01-01T00:00:00Z

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In all the databases and lanugages I have used LIKE pattern matching is based on text or character type of information. You could always convert ActivityDate if it is date into a character column. Usually it makes much more sense to do a:
WHERE
ActivityDate BETWEEN
CAST('2017-01-01T00:00:00' AS DATETIME) AND CAST('2018-12-31T23:59:59' AS DATETIME)
