# Parse files and process them based on creation date

**URL:** https://discourse.nodered.org/t/parse-files-and-process-them-based-on-creation-date/78359
**Category:** General
**Tags:** function-node
**Created:** [11 May 2023 15:16 UTC](https://discourse.nodered.org/t/parse-files-and-process-them-based-on-creation-date/78359 "2023-05-11T15:16:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Alexandre1987](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@Alexandre1987](https://discourse.nodered.org/u/Alexandre1987)
#### Post date: [11 May 2023 15:16 UTC](https://discourse.nodered.org/t/parse-files-and-process-them-based-on-creation-date/78359/1 "2023-05-11T15:16:04Z")

</div>

Hello everybody,  
I have a nodered flow that allows me to grab files from an 'orders\_json' folder, convert them to csv and drop them into an 'order\_csv' folder.  
For technical questions I cannot empty the files deposited progressively in my Json folder.  
In my specific case, I would have to be able to parse only the files uploaded in the last 24 hours.

At the beginning of my flow with the node 'File Lister', I have the possibility of recovering the date of creation of the file.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/588c877862ffebcab7a3f6e613fe047cb767a765.png)

The idea is to have this condition:  
If the creation date of my file is between today's date (Ex: 11-05-23) and yesterday's date (Ex: 10-05-23) then I process my file. If not, I do not process my file.

I tried several ways, tests by creating a function or with a switch and an expression in JSONata. But I haven't found the solution yet.  
I also watched some tutorials but they seem complex for a function that could be quite simple.

If any of you have a solution, I would greatly appreciate it.

Thank's a lot for your help

Alexandre

---

<div class="post-metadata">

### Author: ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)
#### Post date: [11 May 2023 15:31 UTC](https://discourse.nodered.org/t/parse-files-and-process-them-based-on-creation-date/78359/2 "2023-05-11T15:31:15Z")

</div>

To make it easier to compare the dates consider using [toLocaleString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString) or [Moment.js](https://thecodebarbarian.com/formatting-javascript-dates-with-moment-js.html) to format them as in your examples:

> [@](#):
>
> today's date (Ex: 11-05-23) and yesterday's date (Ex: 10-05-23)

if you only wish to go by date and not time.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [10 July 2023 15:31 UTC](https://discourse.nodered.org/t/parse-files-and-process-them-based-on-creation-date/78359/3 "2023-07-10T15:31:54Z")

</div>

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