[Zope] Date Manipulation

Martijn Pieters mj@antraciet.nl
Wed, 03 Mar 1999 10:05:35 +0100


At 05:10 03/03/99 , Luke Duff wrote:
>I'm *really* newbie. I have table with data like this:
>
>field1 field2
>------ ------
>red    3/1/99
>blue   3/1/99
>green  3/1/99
>brown  3/2/99
>yellow 3/2/99
>
>I'd like to render this in DTML from the data:
>
>Monday, March 1
>  red
>  blue
>  green
>Tuesday, March 2
>  brown
>  yellow
>
>How do I do that?
>

You can use the #in tag's grouping features for this. If you use GROUP BY in
your SELECT statement, or use the appropriate sorting, you can use the
following DTML code to get the desired output, assuming the column names are
the same as in your example:

<!--#in MySQLMethod sort=field2-->
<!--#if first-field2-->
    <!--#var field2 fmt="DayOfWeek"-->, 
    <!--#var field2 fmt="Month"-->
    <!--#var field2 fmt="day"--><BR>
    <BLOCKQUOTE>
<!--#/if-->

<!--#var field1-->

<!--#if last-field2-->
    </BLOCKQUOTE>
<!--#/if-->

<!--#else-->
Sorry, no colors in your query.
<!--#/in-->

The variables first-xxx and last-xxx are set whenever the field with name xxx
starts/ends in a sequence. For more information on this, read the Zope DTML
User's Guide (http://www.zope.org/Documentation/Guides/DTML


--
M.J. Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-6254545 Fax: +31-35-6254555
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------