I have a related problem:
I like to calculate time differences with a custom SQL query to
optimize speed. The db cursor seems to return a DateTimeDelta object
(is that a psycopg class?) which I need to convert to a
datetime.timedelta to interoperate with other time objects in Django.
On the othe
Despite being more appropriate for comp.lang.python, this is just an
example I came across for anyone that follows this thread:
# Adding to or Subtracting from a Date
# Use the rather nice datetime.timedelta objects
now = datetime.date(2003, 8, 6)
difference1 = datetime.timedelta(days=1)
differe
Excellent - thanks for those - it's easy to get convoluted code when
you're thinking on an entirely different tack.
Luke Skibinski Holt
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post
Hi,
On Wed, 2006-02-22 at 19:12 -0800, Luke Skibinski Holt wrote:
> dt = datetime.now()
> dt.replace(day=28, month=2)
> wd = dt.weekday()
> sat = dt.replace(day=dt.day+(5-wd))
> sun = dt.replace(day=dt.day+(6-wd))
>>> from datetime import datetime, timedelta
>>> dt = datetime(2006, 2, 28)
>>> wd
On Wed, 2006-02-22 at 19:12 -0800, Luke Skibinski Holt wrote:
> Is there a means of getting a datetime object as an offset from the
> current date?
> I need to get the datetime objects for the coming weekend, but if my
> result is greater than the number of days in a month it fails rather
> than w
5 matches
Mail list logo