PrincipiaTime with MS-Access ODBC data
I have an Access database that I get to via ODBC. One of the columns is type "Date/Time". I want to see if a record is "recent", as in the previous 7 days. I've tried various things, where DocumentTime is the Date/Time field type... <!--#if "PrincipiaTime() - PrincipiaTime(DocumentTime) < 7"--> and <!--#if "PrincipiaTime(DocumentTime+7).isFuture()"--> But I keep getting this error: Error type: Error value: __mul__ nor __rmul__ defined for these operands File E:\Program Files\ZopeOne\lib\python\DocumentTemplate\DT_Util.py, line 268, in eval (Object: PrincipiaTime(DocumentDate)) File <string>, line 0, in ? File E:\Program Files\ZopeOne\lib\python\OFS\Application.py, line 283, in PrincipiaTime (Object: ApplicationDefaultPermissions) File E:\Program Files\ZopeOne\lib\python\DateTime\DateTime.py, line 506, in __init__ TypeError: (see above) (the above trace is from a simple #if "PrincipiaTime(DocumentTime)" Any suggestions? Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com (315)268-9812 Fax netmeeting: ils://ils.murkworks.com ICQ: 14856937 We must come down from our heights, and leave our straight paths, for the byways and low places of life, if we would learn truths by strong contrasts; and in hovels, in forecastles, and among our own outcasts in foreign lands, see what has been wrought upon our fellow-creatures by accident, hardship, or vice. - Richard Henry Dana, Jr. 1836
Brad Clements wrote:
I have an Access database that I get to via ODBC. One of the columns is type "Date/Time".
This means that you get a DbiDate object, assuming that you use the standard odbc interface. I looked into the DateTime.py module. It appears to me as if it tries to build a DateTime from such a dbi object.
I want to see if a record is "recent", as in the previous 7 days.
I've tried various things, where DocumentTime is the Date/Time field type...
<!--#if "PrincipiaTime() - PrincipiaTime(DocumentTime) < 7"-->
I never used this and I'm very new to Zope, but I would try to wrap float() around it if that helps. The DateTime doc says that for a single float argument, it is interpreted as the output of time.time(). Then, a warning: With dbi, you cannot express dates before 1970. Access allows dates from about 1900. This has the weird effect that the DbiDate object will get an internal value of -1, and str() will give you some ugly string from memory but nothing useful. If you have such dates, I'd recommend to switch to the COM interface, either by DAO, or the new general ADO interface which should work with all odbc sources. ciao - chris -- Christian Tismer :^) <mailto:tismer@appliedbiometrics.com> Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.skyport.net 10553 Berlin : PGP key -> http://pgp.ai.mit.edu/ we're tired of banana software - shipped green, ripens at home
On 5 Feb 99, at 15:58, Christian Tismer wrote:
Brad Clements wrote:
I have an Access database that I get to via ODBC. One of the columns is type "Date/Time".
This means that you get a DbiDate object, assuming that you use the standard odbc interface.
I looked into the DateTime.py module. It appears to me as if it tries to build a DateTime from such a dbi object.
I want to see if a record is "recent", as in the previous 7 days.
I've tried various things, where DocumentTime is the Date/Time field type...
<!--#if "PrincipiaTime() - PrincipiaTime(DocumentTime) < 7"-->
The solution was very simple <!--#if DocumentTime + 7 > PrincipiaTime()"--> This will be true for documents with date within the previous 7 days. Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com (315)268-9812 Fax netmeeting: ils://ils.murkworks.com ICQ: 14856937 We must come down from our heights, and leave our straight paths, for the byways and low places of life, if we would learn truths by strong contrasts; and in hovels, in forecastles, and among our own outcasts in foreign lands, see what has been wrought upon our fellow-creatures by accident, hardship, or vice. - Richard Henry Dana, Jr. 1836
participants (2)
-
Brad Clements -
Christian Tismer