AWS DynamoDB Get all items in a table sorted and also get all items that have a modified or created date (2 fields) in the last 3 days

Hello, I have a table with 4 data:

  • creation date format dd/m/YYYY hh:mm:ss
  • date modification format dd/m/YYYY hh:mm:ss
  • timestamp creation date,
  • timestamp modification date

I need two things:

  1. How can I order the results by any of these fields?
  2. How can I get the records created or modified in the last 3 days?

Hi @Jorgelig, welcome to the community!

  1. How can I order the results by any of these fields?

I’d try to parse the date and format it as a ISO 8601-string. This allows easy sorting afterwards using the Item Lists node. To help with the parsing, n8n includes Luxon.

  1. How can I get the records created or modified in the last 3 days?

Once you’ve parsed the dates you can do this with the IF or the Filter node.

Here’s a quick workflow defining a buch of example items using your fecha_registro date format, then sorting and filtering them:

I hope this makes sense and helps! The .fromFormat() method I am using here can parse pretty much anything. If you ever need to parse another format you can find all available tokens describing a date format here.

Hello!

Thank you so much for your response and the advice on sorting the results. I will definitely consider that option as it might be helpful.

I understand that fetching all the records could be costly, so I need to utilize the native filters of n8n’s DynamoDB module to bring fewer records per query.

image

Hey @Jorgelig, you can also use filter expressions which you already seem to do as per your screenshot. This isn’t n8n specific-functionality though (n8n would simply send your expression to the AWS API), so you’d want to check out the AWS documentation for more information here:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.