# Send automatic mail when record was updated two hours ago

**URL:** https://discuss.tryton.org/t/send-automatic-mail-when-record-was-updated-two-hours-ago/890
**Category:** Developer
**Created:** [November 16, 2018, 1:09pm UTC](https://discuss.tryton.org/t/send-automatic-mail-when-record-was-updated-two-hours-ago/890 "2018-11-16T13:09:52Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![nlopez73](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/nlopez73/32/1310_2.png) [@nlopez73](https://discuss.tryton.org/u/nlopez73)
#### Post date: [November 16, 2018, 1:09pm UTC](https://discuss.tryton.org/t/send-automatic-mail-when-record-was-updated-two-hours-ago/890/1 "2018-11-16T13:09:52Z")

</div>

Hello, we need to send an automatic mail two hours later than a record update.

We use notification\_email and “on\_time” trigger but have some problems with pyson expression. We try to use this pyson expression:

Greater(Get(Eval(u’self’, {}), u’write\_date’, u’'), DateTime(delta\_hours=2))

but it doesn’t work because the expression is wrong

What is the best way to do that?

Thanks in advance

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 16, 2018, 2:29pm UTC](https://discuss.tryton.org/t/send-automatic-mail-when-record-was-updated-two-hours-ago/890/2 "2018-11-16T14:29:23Z")

</div>

> [@nlopez73](#):
>
> but it doesn’t work because the expression is wrong

Could you explain what is wrong?

---

<div class="post-metadata">

### Author: ![nlopez73](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/nlopez73/32/1310_2.png) [@nlopez73](https://discuss.tryton.org/u/nlopez73)
#### Post date: [November 16, 2018, 5:24pm UTC](https://discuss.tryton.org/t/send-automatic-mail-when-record-was-updated-two-hours-ago/890/3 "2018-11-16T17:24:49Z")

</div>

> [@ced](#):
>
> > [@nlopez73](#):
> >
> > but it doesn’t work because the expression is wrong
> 
> Could you explain what is wrong?

When I write this expression at trigger form it appear as wrong. I think Greater function don’t allow datetime parameters

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 16, 2018, 5:27pm UTC](https://discuss.tryton.org/t/send-automatic-mail-when-record-was-updated-two-hours-ago/890/4 "2018-11-16T17:27:47Z")

</div>

No it is because the default value for Get (which is used to define the type) is not a datetime.

---

<div class="post-metadata">

### Author: ![nlopez73](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/nlopez73/32/1310_2.png) [@nlopez73](https://discuss.tryton.org/u/nlopez73)
#### Post date: [November 16, 2018, 9:04pm UTC](https://discuss.tryton.org/t/send-automatic-mail-when-record-was-updated-two-hours-ago/890/5 "2018-11-16T21:04:00Z")

</div>

> [@ced](#):
>
> No it is because the default value for Get (which is used to define the type) is not a datetime.

I tried to write it with default value for Get and:  
Greater(Get(Eval(u’self’, {}), u’write\_date’, DateTime(1)), DateTime(delta\_hours=2)) don’t work but  
Equal(Get(Eval(u’self’, {}), u’write\_date’, DateTime(1)), DateTime(delta\_hours=2)) was ok

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [November 16, 2018, 9:41pm UTC](https://discuss.tryton.org/t/send-automatic-mail-when-record-was-updated-two-hours-ago/890/6 "2018-11-16T21:41:31Z")

</div>

Indeed you are right Date, DateTime and Decimal are not yet supported by PYSON: [Suport Date, DateTime and Decimal fields in Greater/Less Pyson statement (#4879) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue4879)
