title: DynamoDB table query KeyConditionExpression error
body: <p>How do I fix the below error and why does "operand type: M" show up? I have read aws docs and searched on stack overflow, but still couldn't solve this problem after a few hours. I want to query an item that is active and has a dateSold between the start and end date in iso format. I am interpreting the error "operand type: M" to mean that I am using the map type in my operands: dateSold, :start, and :end. However, all the operands are just strings. </p>
  
  <p>The SQL command would have looked something like:
  SELECT dateSold, profit FROM Items WHERE isActive = 'true' AND dateSold > start AND dateSold &lt; end </p>
  
  <p>Error: 
  "message":"Invalid KeyConditionExpression: Incorrect operand type for operator or function; operator or function: BETWEEN, operand type: M","code":"ValidationException"</p>
  
  <p>Code: </p>
  
  <pre><code>AWS.config.update({ region: "us-east-2" });
      const documentClient = AWS.DynamoDB.DocumentClient({ apiVersion: "2012-08-10" });
  
      const options = {
          TableName: "Items",
          ProjectionExpression: "dateSold, profit",
          IndexName: "isActive-dateSold-index",
          KeyConditionExpression:
            "isActive = :isActive AND dateSold BETWEEN :start AND :end",
          ExpressionAttributeValues: {
            ":start": { S: start.toISOString() },
            ":end": { S: end.toISOString() },
            ":isActive": { S: "true" },
          },
        }
  
      const result = await documentClient
        .query(options)
        .promise()
  </code></pre>
  
  <p>Schema:</p>
  
  <pre><code>Table: {
      AttributeDefinitions: [
      { AttributeName: "dateSold", AttributeType: "S" },
      { AttributeName: "id", AttributeType: "S" },
      { AttributeName: "isActive", AttributeType: "S" },
      ],
      TableName: "Items",
      KeySchema: [{ AttributeName: "id", KeyType: "HASH" }],
      GlobalSecondaryIndexes: [
      {
          IndexName: "isActive-dateSold-index",
          KeySchema: [
          { AttributeName: "isActive", KeyType: "HASH" },
          { AttributeName: "dateSold", KeyType: "RANGE" },
          ],
      },
      ],
  },
  </code></pre>