Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

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.

View solution in original post

4 Replies
petter
Partner - Champion III
Partner - Champion III

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.

Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

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

petter
Partner - Champion III
Partner - Champion III

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)