Skip to Content
Menu
This question has been flagged
2 Replies
3218 Views

I've created a domain for display last 12 hours orders, but it doesn't work correctly...

<field name="domain">[('create_date','&gt;=', (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))),

('create_date','&lt;=', ((datetime.datetime.now()- datetime.timedelta(hours=12)).strftime('%Y-%m-%d %H:%M:%S'))) ]</field>


Avatar
Discard
Author

I am getting following error: Uncaught Error: TypeError: unsupported operand type(s) for -: 'datetime' and 'timedelta'.

Best Answer

Hello,

Please write down your domain  as like below, it will work.

<field name="domain">[('create_date','&gt;=', (time.strftime('%%Y-%%m-%%d %%H:%%M:%%S'))),
('create_date','&lt;=', ((context_today() - datetime.timedelta(hours=12)).strftime('%%Y-%%m-%%d %%H:%%M:%%S'))) ]</field>


Please try with this and give your result. Hope it will work for you.


Avatar
Discard
Author

Thanks for your help... But still I am getting following error using this code: "Error: ValueError: No known conversion for %H"

Related Posts Replies Views Activity
4
Apr 24
170719
0
Dec 23
602
5
Nov 24
217110
1
Dec 22
1692
2
Nov 22
1678