I have this table that has this line on it as you can see below:
id,"data_dia","nome_completo","nome_produto","nome_tuna","numero_socio","preco_quantidade","quantidade","tipo","valor_conta","valor_pagamento"
compra_pagamento,"2024-11-09T01:26:57.748Z","","chupa chups","joker","177","0.4","1","compra","'-0.40","null"
As I run this code the table returns the line properly
const params = {
TableName: 'HISTORICO-teste',
KeyConditionExpression: 'id = :id AND data_dia BETWEEN :data_inicial AND :data_final',
ScanIndexForward: false,
FilterExpression: '#nome_tuna = :nome_tuna',
ExpressionAttributeNames: { '#nome_tuna': 'nome_tuna' },
ExpressionAttributeValues: {
':data_inicial': '2024-08-07T00:00:00.000Z',
':data_final': '2025-07-08T23:59:59.999Z',
':nome_tuna': 'joker',
':id': 'compra_pagamento'
}
}
await dynamo.query(params).then(result => {
console.log(result.Items);
});
But if I change the code to reflect a data greater then the one above it doesn't return the line
soo if for example, I change the
':data_final': '2025-07-08T23:59:59.999Z'
START RequestId: 8a743c09-4f50-44d3-bbac-6e0bdfcebf5b Version: $LATEST
2025-07-16T15:28:10.330Z 8a743c09-4f50-44d3-bbac-6e0bdfcebf5b INFO 2024-08-07T00:00:00.000Z
2025-07-16T15:28:10.330Z 8a743c09-4f50-44d3-bbac-6e0bdfcebf5b INFO 2025-07-08T23:59:59.999Z
2025-07-16T15:28:10.430Z 8a743c09-4f50-44d3-bbac-6e0bdfcebf5b INFO [
{
nome_produto: 'chupa chups',
tipo: 'compra',
data_dia: '2024-11-09T01:26:57.748Z',
valor_pagamento: null,
valor_conta: '-0.40',
numero_socio: 177,
quantidade: 1,
id: 'compra_pagamento',
nome_tuna: 'joker',
nome_completo: '',
preco_quantidade: 0.4
}
]
END RequestId: 8a743c09-4f50-44d3-bbac-6e0bdfcebf5b
REPORT RequestId: 8a743c09-4f50-44d3-bbac-6e0bdfcebf5b Duration: 111.26 ms Billed Duration: 112 ms Memory Size: 2000 MB Max Memory Used: 91 MB Init Duration: 382.70 ms
to
':data_final': '2025-07-09T23:59:59.999Z'
START RequestId: 845c6a5e-379d-432e-99db-340bc912bec0 Version: $LATEST
2025-07-16T15:30:25.621Z 845c6a5e-379d-432e-99db-340bc912bec0 INFO 2024-08-07T00:00:00.000Z
2025-07-16T15:30:25.622Z 845c6a5e-379d-432e-99db-340bc912bec0 INFO 2025-07-09T23:59:59.999Z
2025-07-16T15:30:25.721Z 845c6a5e-379d-432e-99db-340bc912bec0 INFO []
END RequestId: 845c6a5e-379d-432e-99db-340bc912bec0
REPORT RequestId: 845c6a5e-379d-432e-99db-340bc912bec0 Duration: 109.04 ms Billed Duration: 110 ms Memory Size: 2000 MB Max Memory Used: 91 MB Init Duration: 381.52 ms
another bit of information, I have a bunch of others lines of data almost everyday from the date 2024-08-07T00:00:00.000Z to now
Edit:
Also updated to add both of the results when i change the final date.
On the aws console it works correctly

data_finalis not what you think it is. From your description it sounds like thatdata_finalis some string which is, when compared as string less thandata_initial. Maybe you have a typo in your value, for instance a leading whitespace or similar. Is that value hardcoded or entered by the user? Please post the exact code that is failing ...