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 get date max in next month?

By
Miftah
on 1/12/15, 8:42 AM 838 views

If we will take date max in this month, can use this code :

 

date_now = datetime.today()
date_max = date_now.max.day

 

But how to take date max in next month?

0

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
3918
| 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 1/12/15, 8:58 AM

Try this,

from dateutil.relativedelta import relativedelta
from datetime import datetime
next_month = datetime.today() + relativedelta(months=1)
date_max=next_month.max.day

0

Bole

--Bole--
2385
| 5 4 6
Zagreb | Karlovac, Croatia
--Bole--

there is only 10 kind of people the ones that understand binary ... and others

Bole
On 1/12/15, 8:50 AM

import calendar
date_now = datetime.today()
day_max = calendar.monthrange(date_now.year, date_now.month +1 )[1]  # return tuple( 1.st day, number of days)

hope it 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

1 follower(s)

Stats

Asked: 1/12/15, 8:42 AM
Seen: 838 times
Last updated: 7/10/15, 10:50 AM