1 Aug 2008 16:47
How to add explicit types so I can use OVERLAPS?
I want to use the OVERLAPS keyword to compare two time intervals, but
I'm having trouble.
In the code below, I want to test if the time interval from 9:15 AM
through 9:45 AM overlaps the time interval from 8 AM through 10 AM.
This approach fails:
>>> d = {'9:15 AM':datetime(2008, 8, 1, 9, 15),
... '9:45 AM':datetime(2008, 8, 1, 9, 45),
... '8 AM':datetime(2008, 8, 1, 8),
... '10 AM':datetime(2008, 8, 1, 10)}
>>> cursor.execute('select (%(9:15 AM)s, %(9:45 AM)s) '
... 'overlaps (%(8 AM)s, %(10 AM)s);', d)
------------------------------------------------------------
Traceback (most recent call last):
File "<ipython console>", line 1, in <module>
ProgrammingError: function pg_catalog.overlaps(unknown, unknown,
unknown, unknown) is not unique
LINE 1: ...ct ('2008-08-01T09:15:00', '2008-08-01T09:45:00') overlaps
(...
^
HINT: Could not choose a best candidate function. You might need to add
explicit type casts.
Meanwhile, this approach works fine:
>>> cursor.execute('select (TIMESTAMP %(9:15 AM)s, TIMESTAMP %(9:45 AM)s) '
(Continue reading)
RSS Feed