DynamoDB: Query Date Range (Guide w/ Code Examples)

Provided by Rafal Wilinski
To query a date range using the AWS JavaScript SDK, you can use the query operation.
var AWS = require('aws-sdk'); var dynamo = new AWS.DynamoDB({region: 'us-west-2'}); var params = { TableName: 'my-table', KeyConditionExpression: '#timestamp between :start_date and :end_date', ExpressionAttributeNames: { '#timestamp': 'timestamp' }, ExpressionAttributeValues: { ':start_date': {N: '1577836800'}, // January 1, 2020 ':end_date': {N: '1609459200'} // December 31, 2020 } }; dynamo.query(params, function(err, data) { if (err) { console.error(err); } else { console.log(data); } });
In this example, the KeyConditionExpression is set to check if the timestamp attribute is between :start_date and :end_date. The ExpressionAttributeNames and ExpressionAttributeValues are used to map the attribute names and values used in the expression to the actual attribute names and values in the table.
Similar Code Examples
- DynamoDB BatchWriteItem in Typescript
- DynamoDB: Attribute Not Null
- DynamoDB: Get Unique Values
- DynamoDB: Delete Table
- DynamoDB: Query Group By
- DynamoDB: Query Greater Than
- DynamoDB: Query JSON
- DynamoDB: Increment Counter
- DynamoDB: Delete Multiple Items in Javascript
- DynamoDB: Query Global Secondary Index in Nodejs
- DynamoDB: Query KeyConditionExpression
- DynamoDB: GetItem
- DynamoDB: Get By ID
- DynamoDB: Like
- DynamoDB: Get Random Item
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
- New in Dynobase 3.0
- Semantic and Vector Search
- Schema Explorer
- Visual JSON Path Filtering
- Visual Item Diff
- MCP Server for AI Tools
- Use SQL with DynamoDB
- Import CSV To DynamoDB
- Import JSON To DynamoDB
- Export DynamoDB To JSON
- Export DynamoDB To S3
- Export DynamoDB To CSV
- DynamoDB Update Item
- DynamoDB Delete All Items
- DynamoDB Delete Item
- DynamoDB Create Table
- DynamoDB Delete Table
- DynamoDB Conditional Update
DynamoDB Tools
DynamoDB Info
© 2026 Dynobase