Re: Add a month

2006-02-17 Thread Gregory Piñero
Ok, 30 minutes later, here's my best solution. http://www.answermysearches.com/index.php/how-to-add-months-to-a-date-in-python/53/ (Posted on my website to make sure tabs are kept.) Would someone mind double-checking my logic before I put this into production next Tuesday? -Greg On 2/17/06, G

Re: Add a month

2006-02-17 Thread Jarek Zgoda
Paul Boddie napisał(a): >>what do you expect d_new to be after the operation ? if the answer >>is date(2006,3,17), what's date(2006,1,31) plus one month? > > February 31st, of course: > > http://sql-info.de/mysql/gotchas.html#1_14 MS SQL Server documentation marks dateadd() result as non-deter

Re: Add a month

2006-02-17 Thread Carsten Haese
On Fri, 2006-02-17 at 16:10, Gregory Piñero wrote: > Actually, no wait, that's bad. It doesn't increment the year. > > Does anyone have a simple way to code this? > > -Greg > > > On 2/17/06, Gregory Piñero <[EMAIL PROTECTED]> wrote: > > Here's how I do it: > > > > def monthify(anint): > >

Re: Add a month

2006-02-17 Thread Gregory Piñero
Actually, no wait, that's bad. It doesn't increment the year. Does anyone have a simple way to code this? -Greg On 2/17/06, Gregory Piñero <[EMAIL PROTECTED]> wrote: > Here's how I do it: > > def monthify(anint): > if anint%12==0:return 12 > else:return anint%12 > > import datetime > d

Re: Add a month

2006-02-17 Thread Gregory Piñero
Here's how I do it: def monthify(anint): if anint%12==0:return 12 else:return anint%12 import datetime d=datetime.datetime.today() dplus1month=datetime.datetime(d.year,monthify(d.month+1),d.day) We need monthify because adding 1 to 12 is bad otherwise! -Greg On 17 Feb 2006 04:15:39 -08

Re: Add a month

2006-02-17 Thread Paul Boddie
Fredrik Lundh wrote: > > what do you expect d_new to be after the operation ? if the answer > is date(2006,3,17), what's date(2006,1,31) plus one month? February 31st, of course: http://sql-info.de/mysql/gotchas.html#1_14 ;-) Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Add a month

2006-02-17 Thread Daniel Dittmar
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > >> Hi, this is probably a really simple question but... >> How do you add a month to a datetime date in python? It would be nice >> if you could do something like: >> >> d = datetime.date(2006,2,17) >>

Re: Add a month

2006-02-17 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Hi, this is probably a really simple question but... > How do you add a month to a datetime date in python? It would be nice > if you could do something like: > > d = datetime.date(2006,2,17) > dm = datetime.timedelta(months=1) > d_new = d +

Re: Add a month

2006-02-17 Thread Raymond Hettinger
[EMAIL PROTECTED] > Hi, this is probably a really simple question but... > How do you add a month to a datetime date in python? It would be nice > if you could do something like: > > d = datetime.date(2006,2,17) > dm = datetime.timedelta(months=1) > d_new = d + dm > > b

Add a month

2006-02-17 Thread novin01
Hi, this is probably a really simple question but... How do you add a month to a datetime date in python? It would be nice if you could do something like: d = datetime.date(2006,2,17) dm = datetime.timedelta(months=1) d_new = d + dm but timedelta doesn't have a 'months' settin