[Zope] string splitting in dtml
Spicklemire, Jerry
Jerry.Spicklemire@IFLYATA.COM
Mon, 4 Dec 2000 16:38:46 -0500
Mike asked:
> I have a date string (ie dd/mm/yy) which I'm drawing out of a database
> (ODBC connection to Access) with a Z SQL method and I need to use that
> data to set the initial condition of a set of 3 select items (ie day,
> month and year). Is there a way to split this date (it'll come out
> looking like dd/mm/yy) to get the components of it
You could use the Python "string slice" syntax, like so:
<dtml-let day_of_month="_['start_date'][:2]"
month_of_year="_['start_date'][3:5]"
year_of_century="_['start_date'][6:8]">
The <dtml-var day_of_month> day,<br>
of the <dtml-var month_of_year> month,<br>
of the year 20<dtml-var month_of_century><br>
</dtml-let>
Later,
Jerry S.