# Calculate with msg.date from email in node

**URL:** https://discourse.nodered.org/t/calculate-with-msg-date-from-email-in-node/48993
**Category:** General
**Created:** [28 July 2021 04:57 UTC](https://discourse.nodered.org/t/calculate-with-msg-date-from-email-in-node/48993 "2021-07-28T04:57:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tfuchs1987](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tfuchs1987/32/44508_2.png) [@tfuchs1987](https://discourse.nodered.org/u/tfuchs1987)
#### Post date: [28 July 2021 04:57 UTC](https://discourse.nodered.org/t/calculate-with-msg-date-from-email-in-node/48993/1 "2021-07-28T04:57:52Z")

</div>

Hi Forum, I try to calculate with the msg.date object from the email in node

- node-red-node-email v1.12.3

`msg.date = "2021-07-28T04:32:28.000Z"`

Is there a way to querry just the emails recieved in the last X minutes? I hope I dont need to calculate the seconds until 1970 myself 😄

---

<div class="post-metadata">

### Author: ![rko](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rko/32/45807_2.png) [@rko](https://discourse.nodered.org/u/rko)
#### Post date: [28 July 2021 07:42 UTC](https://discourse.nodered.org/t/calculate-with-msg-date-from-email-in-node/48993/2 "2021-07-28T07:42:01Z")

</div>

You could try something like this in a function node:

```auto
let minutes = 50; // email can't be older than 50 minutes

let age = (new Date() - new Date(msg.date)) / (1000 * 60); // age in minutes

// only return if it's not too old
if(age < minutes){
    return msg;
}

```

---

<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: [11 August 2021 07:42 UTC](https://discourse.nodered.org/t/calculate-with-msg-date-from-email-in-node/48993/3 "2021-08-11T07:42:33Z")

</div>

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