[Python] How to filter by date range in dynamodb?

Discussão em 'Python' iniciado por Stack, Janeiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I have following data in dynamo , all string fields.

    id | data | my_date

    1 | some text | 2024-03-21
    2. | more text | 2024-09-30
    ....



    i wrote a query as such, to scan items and then filter by date range. I tried this and it seems it works. is there any other way to add a filter like if there I can do BETWEEN start AND end dates?

    also, when i run this query, i suppose it scans all the items in my table and then filter based on my date range. is there a different(possibly better ) way to filter based on date range?

    {
    TableName: mytable,
    FilterExpression:'my_date > start AND my_date < end',
    ExpressionAttributeValues: {
    ':start': {'S': '2024-06-30'},
    ':end' : {'S': '2024-01-01'}
    }
    }

    Continue reading...

Compartilhe esta Página