[Zope] Newbie date/time + MySQL problem

Monty Taylor mtaylor@goldridge.net
Tue, 25 Apr 2000 20:32:10 +0200


This is a multi-part message in MIME format.
--------------B53B4494859D9E6F7C27600E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

You're probably right, Zope probably doesn't see the date as a date, but
as a string. Try:

  select date_format(date,'%b %e, %Y') as date from table

In your SQL query. I'm sure there's a way to map that to a Zope date,
but if you just need the string, this might be a temp. fix.

Monty

jeffr@odeon.net wrote:
> 
>         Hmm, that didn't work.  I get a Zope error of:
> 
>                 Error Type: TypeError
>                 Error Value: not all arguments converted
> 
>         What I think is the relevent portion of the traceback shows:
> 
>   File /usr/local/Zope/lib/python/DocumentTemplate/DT_Var.py, line 313, in render
>     (Object: date)
>     (Info: ('date', '2000-04-25', {'null': '', 'fmt': 'aCommon', '': 'date'}))
> 
>         I think the problem is the string returned from MySQL isn't a
>         date object as far as Zope is concerned.
> 
>         Any help is appreciated,
> 
>         Jeff
> 
> On Tue, 25 Apr 2000, Yanko, Curtis (GSP) wrote:
> 
> > Just figured this one out myself a week or two ago. I use something like
> > this:
> >
> > <dtml-var date fmt=aCommon>
> >
> > If you are using a Zope Date/Time object, this should work.
> >
> > -Curt
> >
> > > -----Original Message-----
> > > From:       jeffr@odeon.net [SMTP:jeffr@odeon.net]
> > > Sent:       Tuesday, April 25, 2000 12:02 PM
> > > To: zope@zope.org
> > > Subject:    [Zope] Newbie date/time + MySQL problem
> > >
> > >
> > >     Greetings folks,
> > >
> > >     I've got a record in an SQL database that contains a date
> > >     field (2000-02-25 for example).
> > >
> > >     I'm generating a table from an SQL query.  The bit that displays
> > >     the date is pretty simple: <dtml-var date null="">
> > >
> > >     I want to format the date into something a little more readable
> > >     (like 'Feb 25, 2000' for example).  I've been trying to figure out
> > >     how to use the date-time format functions mentioned in the DTML
> > >     guide in Appendix A.  It mentions the special variable _, which
> > >     provides a method for constructing date time values from strings
> > >     and numeric data.
> > >
> > >     I think my question is really a matter of syntax, as the DTML
> > >     guide doesn't provide any examples of usage in Appendix A.
> > >
> > >     Would I use something like: <dtml-var _.aCommon(date) null=""> ?
> > >
> > >     Any help would be greatly appreciated,
> > >
> > >     Jeff
> > >
> > >
> > > _______________________________________________
> > > Zope maillist  -  Zope@zope.org
> > > http://lists.zope.org/mailman/listinfo/zope
> > > **   No cross posts or HTML encoding!  **
> > > (Related lists -
> > >  http://lists.zope.org/mailman/listinfo/zope-announce
> > >  http://lists.zope.org/mailman/listinfo/zope-dev )
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )
> >
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
--------------B53B4494859D9E6F7C27600E
Content-Type: text/x-vcard; charset=us-ascii;
 name="mtaylor.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Monty Taylor
Content-Disposition: attachment;
 filename="mtaylor.vcf"

begin:vcard 
n:Taylor;Monty
tel;cell:+31 (0)6 200 17486
tel;fax:+31 (0)20 589 5566
tel;work:+31 (0)20 589 5517
x-mozilla-html:TRUE
url:http://www.goldridge.net
org:Information Innovation
adr:;;Amstelveenseweg 88-90;Amsterdam;;1075 XJ;The Netherlands
version:2.1
email;internet:mtaylor@goldridge.net
title:Information Artist
x-mozilla-cpt:;0
fn:Monty Taylor
end:vcard

--------------B53B4494859D9E6F7C27600E--