title: How to get items in DynamoDB Table filter based on TimeStamp and an offset of this TimeStamp value?
body: <p>I have DynamoDB table with the following schema:</p>
  
  <pre><code>var params = {
      TableName : "SomeTable",
      KeySchema: [       
          { AttributeName: "userid", KeyType: "HASH"},  //Partition key
          { AttributeName: "transactionId", KeyType: "RANGE" }  //Sort key
      ],
      AttributeDefinitions: [       
          { AttributeName: "userid", AttributeType: "S" },
          { AttributeName: "transactionId", AttributeType: "S" },
      ],
      GlobalSecondaryIndexes: [ 
          { 
             IndexName: "TransactionIndex",
             KeySchema: [ 
                { 
                   AttributeName: "transactionId",
                   KeyType: "HASH"
                },
                { 
                  AttributeName: "productId",
                  KeyType: "RANGE"
               }
             ],
             Projection: { 
                ProjectionType: "ALL"
             },
             ProvisionedThroughput: { 
                ReadCapacityUnits: 10,
                WriteCapacityUnits: 10
             }
          }
       ],
      ProvisionedThroughput: {       
          ReadCapacityUnits: 10, 
          WriteCapacityUnits: 10
      }
  };
  </code></pre>
  
  <p>I am looking to query this table, filtered based on time value, however I cannot find any documentation on how to modify this value in the FilterExpression. The idea is to find all the rows where the expiry_date_ms value is about to expiry, or has just expired (i.e. 1 day before or 1 day after), as follow:</p>
  
  <pre><code>var startoffset = 86400000;         // one day before
  var endoffset = 86400000;         // one day after
  
  var params = { 
      TableName: "SomeTable", 
      FilterExpression: "#tm between :start and :end'",    
      ExpressionAttributeNames: { "#tm": "expiry_date_ms" }, 
      ExpressionAttributeValues:{ ":start": "expiry_date_ms" - startoffset, ":end": "expiry_date_ms" + endoffset }  
  }; 
  
  docClient.scan(params, function(err, data) {
      if (err) {
          console.error("Unable to query. Error:", JSON.stringify(err, null, 2));
      } else {
          console.log(params);
          console.log("Scan succeeded.");        
          data.Items.forEach(function(item) {
              console.log("Item :" + JSON.stringify(item));           
          });
      }
  });
  </code></pre>
  
  <p>Maybe I have the logic completely wrong and there is a better/clever way to run such query or what's the best method, Scan or Query in my case. Any information regarding the issue would be greatly appreciated.</p>