Odoo Help

1

How to extract the month from a date field?

By
Drees Far
on 2/19/16, 5:52 AM 945 views

Hello everybody!!!!

Can anyone help me please.

I have this field type date:

2016-01-01 and i want to get the month then convert it to its name.

Need help friends please.

Best Regards.

0
Kalpana Hemnani
On 3/4/16, 7:38 AM

#import datetime library

from datetime import datetime


month = datetime.strptime('2016-01-01', "%Y-%m-%d").strftime('%B')#Converting a string format datetime into datetime() type.

You can use different directives as per your requirement in place of "%B". You can find them \here.


Best Regards,

Kalpana Hemnani

0

Hi Drees,

     you should use split method of python

i am consider date as year-month-date

data_value='2016-01-01'

get_month=data_value.split('-)[1]

if get_month=='1':

   month_name='january'

if you have such issues issues mail me on virzoteck@gmail.com

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 2/19/16, 5:52 AM
Seen: 945 times
Last updated: 3/4/16, 7:38 AM