title: dynamodb query ExpressionAttributeValues javascript
body: <p>Hey guys so I'm trying to query my dynamo db GIS index for any string is more than a year old on the checkdate column, so my questions is how do you construct the KeyConditionExpression or ExpressionAttributeValues? Any help is appreciated! Refer to code below:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>console.log("Loading function");
  var AWS = require('aws-sdk');
  var lastyeartoday = new Date();
  var dd = lastyeartoday.getDate();
  var mm = lastyeartoday.getMonth()+1;
  var yyyy = lastyeartoday.getFullYear()-1;
  var ddb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
  var s3 = new AWS.S3();
  
  function date(err, lastyeartoday) {
  
  if(dd&lt;10) {
      dd = '0'+dd;
  } 
  
  if(mm&lt;10) {
      mm = '0'+mm;
  } 
  }
  lastyeartoday = mm + '/' + dd + '/' + yyyy;
  
  console.log(lastyeartoday);
  
  
  exports.handler = function(data, context, callback) {
      
      
      var params = {
      TableName: "S3_log",
      IndexName: "Checkdate-index",
      "Select": "ALL_ATTRIBUTES",
      KeyConditionExpression: 'Checkdate = :checkdate',
      ExpressionAttributeValues: {
          ":checkdate": {S: lastyeartoday.toString()},
      },
      ScanIndexForward: true,
      Limit: 1,
      ConsistentRead: false, 
      ReturnConsumedCapacity: 'NONE',
  };
  
  
  ddb.query(params, function(err, data) {
      if (err) {
          callback(err, null);
      } else {
          return(null, data);
  };</code></pre>
  </div>
  </div>
  </p>