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.

1

How to extract the month from a date field?

By
Drees Far
on 2/19/16, 5:52 AM 736 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

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

1 follower(s)

Stats

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