[Zope] Getting the day from a Timestamp / gvibda

Brad Clements bkc@murkworks.com
Tue, 22 May 2001 10:57:34 -0400

On 22 May 2001, at 15:47, Oliver Sturm wrote:

> I have a query returning a timestamp column from my interbase 6 database
> using the Going Virtual database adapter. I want to extract the values of
> the day/month/year ... from the variable. I tried this

Here are two Extension methods I use.. Pick one

def FormatDate(date,format="%a, %B %d %H:%M"):
    """format the date object"""
    if not date:
        return "[unknown]"
    t = list(date.tuple())
    if len(t) < 9:
    return time.strftime(format,t)

def DateTimeCast(s):
    """convert an interbase Timestamp to datetime"""
    if not s: return s
        return apply(DateTime,s.tuple())
    except AttributeError:
        return DateTime(s)

<dtml-var "_.DateTime(date_column.tuple()).day()">

Based on this, I think this DTML might work

Brad Clements,                bkc@murkworks.com   (315)268-1000
http://www.murkworks.com                          (315)268-9812 Fax
netmeeting: ils://ils.murkworks.com               AOL-IM: BKClements