Odoo Help

3

How to get date max in next month?

By
Miftahussalam
on 1/12/15, 8:42 AM 1,392 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
Jainesh Shah
On 6/7/17, 9:27 AM

You can try following code to get next month's last day:

import datetime

from dateutil.relativedelta import relativedelta

next_month_max_day =((datetime.datetime.today().date() + relativedelta(months=+1,day=31))).day

0

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

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: 1/12/15, 8:42 AM
Seen: 1392 times
Last updated: 6/7/17, 9:27 AM