Re: MySQL timediff and datetime.timedelta

2008-09-03 Thread Jens Grivolla

On Sep 2, 12:55 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-09-02 at 03:16 -0700, JensGrivollawrote:
> > I am getting weird results using django.db to do a "select
> > timediff(a,b)..." query from MySQL.  The result is a datetime.datetime
> > object instead of a datetime.timedelta.  When using MySQLdb directly,
> > it returns the expected timedelta object.
>
> Are you really getting a datetime.datetime and not a datetime.time? I
> would have expected you might get the latter, since we map any TIME type
> of column to a datetime.time. I can't see how you would be getting a
> datetime, though.

You are right, it's a datetime.time.  I'd still rather have a
datetime.timedelta (which seems more logical), mostly because I want
to use the timedelta.seconds attribute.  I'm now using
time_to_seconds() in MySQL so I don't have to deal with the time vs.
timedelta issues.

Ciao,
   Jens
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MySQL timediff and datetime.timedelta

2008-09-02 Thread Malcolm Tredinnick


On Tue, 2008-09-02 at 03:16 -0700, Jens Grivolla wrote:
> Hi,
> 
> I am getting weird results using django.db to do a "select
> timediff(a,b)..." query from MySQL.  The result is a datetime.datetime
> object instead of a datetime.timedelta.  When using MySQLdb directly,
> it returns the expected timedelta object. 

Are you really getting a datetime.datetime and not a datetime.time? I
would have expected you might get the latter, since we map any TIME type
of column to a datetime.time. I can't see how you would be getting a
datetime, though.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



MySQL timediff and datetime.timedelta

2008-09-02 Thread Jens Grivolla

Hi,

I am getting weird results using django.db to do a "select
timediff(a,b)..." query from MySQL.  The result is a datetime.datetime
object instead of a datetime.timedelta.  When using MySQLdb directly,
it returns the expected timedelta object.  The code is exactly
identical in both cases other than using django.db.connection instead
of MySQLdb.connect(...)

I'm using default packages on Ubuntu 8.04 (django 0.96.1-2ubuntu2,
mysqldb 1.2.2-5ubuntu1, mysql 5.0.51a-3ubuntu5.1).

Any clues?

Thanks,
Jens

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---