Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to find out number of hours between two datetime object?

By
Odoo
on 12/2/14, 11:19 PM 836 views

 'date_from':fields.datetime('Date From'),
  'date_to':fields.datetime('Date To'),

 

d_frm_obj = datetime.datetime.strptime(date_from, DEFAULT_SERVER_DATETIME_FORMAT)
 d_to_obj = datetime.datetime.strptime(date_to, DEFAULT_SERVER_DATETIME_FORMAT)
  temp_date = d_to_obj-d_frm_obj.hours         (This got errors)

From the above code  How to find out the number of hours between these two objects...need a help

Hi, Just write down as like below. *temp_date = d_to_obj-d_frm_obj* *diff_in_sec = temp_date.total_seconds()* *diff_in_hours = diff_in_sec / 60* I hope you will get the difference.

Emipro Technologies Pvt. Ltd.
on 12/3/14, 12:31 AM

Thanks EMI........

Odoo
on 12/3/14, 5:29 AM
0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3883
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 12/3/14, 2:34 AM

Try this

d_frm_obj = datetime.strptime(date_from, DEFAULT_SERVER_DATETIME_FORMAT)
d_to_obj = datetime.strptime(date_to, DEFAULT_SERVER_DATETIME_FORMAT)
temp_date = d_to_obj - d_frm_obj
print temp_date.seconds/3600       //This will provide hours.
print (diff.days *24) + (diff.seconds/3600)    //Provides total number of hours including days 

For more info: http://stackoverflow.com/a/2119512/2470366

Thanks atchuthan ........

Odoo
on 12/3/14, 5:29 AM
0

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 12/3/14, 12:44 AM

Hello Libu

d_frm_obj = datetime.datetime.strptime(date_from, DEFAULT_SERVER_DATETIME_FORMAT)
d_to_obj = datetime.datetime.strptime(date_to, DEFAULT_SERVER_DATETIME_FORMAT)

diff = d_to_obj - d_frm_obj

hours = (diff.seconds)/ 3600
print hours

diff_days = diff.days
print diff_days

days_hours = diff_days * 24
print days_hours

total_hours = days_hours + hours
print total_hours

Hope this helps !!

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 12/2/14, 11:19 PM
Seen: 836 times
Last updated: 3/16/15, 8:10 AM