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
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
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):
> >
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
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
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
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)
>>
[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 +
[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
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
10 matches
Mail list logo