[Zope] Solution: DateTime: Get DateTime-Objekt from german dateformat %d.%m.%Y

Andreas Jung lists at andreas-jung.com
Thu Mar 3 08:47:07 EST 2005



--On Donnerstag, 3. März 2005 14:36 Uhr +0100 Patrick Ulmer 
<ulmer at truckport.de> wrote:

> Hi,
>
>> i have a litte problem to insert my german dateformat into my
>> SQL-Database, because I must convert it to ISO-Format. I try
>>
>> datum=_.DateTime (wiedervorlage).ISO())
>>
>> but day and month ar interchanged.
>>
>> How can I convert my datestring '1.3.2005' to '2005-03-01'?
>
>
> One solution is to put this in an external method:
>
> from time import strftime, strptime
> print strftime("%Y-%m-%d", strptime ("1.3.2005", "%d.%m.%Y"))
>

Why do you make it so complicated? And why don't you modify your SQL
query so that it returns your date in a format e.g. YYYYDDMM can can be 
parsed
by DateTime out-of-the-box? This would be the most straight forward way to 
go.

-aj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20050303/bcc01e29/attachment-0001.bin


More information about the Zope mailing list