[Zope] Date format question urgent!!!

Marko MARKOVIC marko.markovic@isp.lu
Thu, 27 Jul 2000 09:33:39 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_001E_01BFF7AD.BF0A2820
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hi all,

i have a few questions about date formating:


i work with a sybase database and have tables where i used date fields. =
My field entrydate is of type Date.

on my page i have a textbox to put the date:
=20
<input type=3D"text" name=3D"new_nsentrydate" value=3D"01.01.2000" =
size=3D"10">

i will formating it as 2000/01/01 and then put it in a sql query as a =
parameter. For the formating i use the follow code:=20

<dtml-with "_.DateTime(new_nsentrydate)">
  <dtml-var " '%s/%s/%s' % (year(), mm(), dd())">
</dtml-with>

and i get 2000/01/01.

Here is my dtml-code:

<dtml-with "_.DateTime(new_nsentrydate)">
  <dtml-var "'%s/%s/%s' % (year(), mm(), dd())">
</dtml-with>

<dtml-with "_.DateTime(new_nsbirthday)">
  <dtml-var "'%s/%s/%s' % (year(), mm(), dd())">
</dtml-with>

with this code :

<dtml-call "insertNoteService(nsentrydate =3D =
"_.DateTime(new_nsentrydate)" '%s/%s/%s' % (year(), mm(), dd()), nsname =
=3D new_nsname,=20
                              nsadresse =3D new_nsadresse, nslocation =
=3D new_nslocation,=20
                              nscountry =3D new_nscountry, nsbirthday =
=3D "_.DateTime(new_nsbirthday)" '%s/%s/%s' % (year(), mm(), dd()),
                              nsbirthplace =3D new_nsbirthplace, nstext =
=3D new_nstext,
                              nsstatus =3D 0, nstype =3D new_nstype, =
nssociety =3D new_nssociety,=20
                              nsservice =3D new_nsservice)">

i get the folowing error:

Invalid attribute name, "_.DateTime(new_nsentrydate)", for tag =
<dtml-call "insertNoteService(nsentrydate =3D =
"_.DateTime(new_nsentrydate)" '%s/%s/%s' % (year(), mm(), dd()), nsname =
=3D new_nsname, nsadresse =3D new_nsadresse, nslocation =3D =
new_nslocation, nscountry =3D new_nscountry, nsbirthday =3D =
"_.DateTime(new_nsbirthday)" '%s/%s/%s' % (year(), mm(), dd()), =
nsbirthplace =3D new_nsbirthplace, nstext =3D new_nstext, nsstatus =3D =
0, nstype =3D new_nstype, nssociety =3D new_nssociety, nsservice =3D =
new_nsservice)">, on line 4 of addNoteService_html

with this code :

<dtml-call "insertNoteService(nsentrydate =3D =
"_.DateTime(new_nsentrydate)" '%s/%s/%s' % (year(), mm(), dd())", nsname =
=3D new_nsname,=20
                              nsadresse =3D new_nsadresse, nslocation =
=3D new_nslocation,=20
                              nscountry =3D new_nscountry, nsbirthday =
=3D "_.DateTime(new_nsbirthday)" '%s/%s/%s' % (year(), mm(), dd())",
                              nsbirthplace =3D new_nsbirthplace, nstext =
=3D new_nstext,
                              nsstatus =3D 0, nstype =3D new_nstype, =
nssociety =3D new_nssociety,=20
                              nsservice =3D new_nsservice)">

i don't get  Errors, but it doesn't work.


Here is my sql code:

INSERT INTO noteservice (ns_entrydate, ns_name,
       ns_adresse, ns_location, ns_country, ns_birthday,
       ns_birthplace, ns_text, ns_status, ns_type,
       ns_society, ns_service)
VALUES('<dtml-var nsentrydate>', '<dtml-var nsname fmt=3Dsql-quote>', =
'<dtml-var nsadresse fmt=3Dsql-quote>', '<dtml-var nslocation =
fmt=3Dsql-quote>', '<dtml-var nscountry fmt=3Dsql-quote>', '<dtml-var =
nsbirthday>','<dtml-var nsbirthplace fmt=3Dsql-quote>', '<dtml-var =
nstext fmt=3Dsql-quote>', <dtml-var nsstatus>, <dtml-var nstype>, =
<dtml-var nssociety>, <dtml-var nsservice>)  =20

when i use this code :

<dtml-with "_.DateTime('01.01.1900')">
<dtml-var  "'%s/%s/%s' % (year(), mm(), dd())">
</dtml-with>

i get 1900/01/01

when i use this code :

<dtml-let tert=3D"'01.01.1900'">
 <dtml-var "_.DateTime(tert)" fmt=3D"%Y/%m/%d">
</dtml-let>

i get 2036/02/07         Why?

when i use this code :

<dtml-var "_.DateTime('01.01.1900')" fmt=3D"%Y/%m/%d">

i get 2036/02/07         Why?

when i use this code :

<dtml-var "ZopeTime('01.01.1900')" fmt=3D"%Y/%m/%d">

i get 2036/02/07         Why?

Could you explain me how i must handle date fields in zope?


Finally, i want formatting a date as 2000/01/01 and then put in my table =
with a sql method.

Any suggestions or a good example will be apprecieated...                =
       =20



$Regards

MM

------=_NextPart_000_001E_01BFF7AD.BF0A2820
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial>hi all,</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>i have a few questions about date =
formating:</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>i work with a sybase database and have tables =
where i used=20
date fields. My field entrydate is of type Date.</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>on my page i have a textbox to put the =
date:</FONT></DIV>
<DIV><FONT face=3DArial>&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>&lt;input type=3D"text"=20
name=3D"new_nsentrydate" value=3D"01.01.2000" =
size=3D"10"&gt;</STRONG></FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>i will formating it as 2000/01/01 and then put =
it in a sql=20
query as a parameter.&nbsp;For the formating i use the follow=20
code:</FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>&lt;dtml-with=20
"_.DateTime(new_nsentrydate)"&gt;<BR>&nbsp; &lt;dtml-var " '%s/%s/%s' % =
(year(),=20
mm(), dd())"&gt;<BR>&lt;/dtml-with&gt;</STRONG></FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>and i get 2000/01/01.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>Here is my dtml-code:</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>&lt;dtml-with=20
"_.DateTime(new_nsentrydate)"&gt;<BR>&nbsp; &lt;dtml-var "'%s/%s/%s' % =
(year(),=20
mm(), dd())"&gt;<BR>&lt;/dtml-with&gt;</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG></STRONG></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>&lt;dtml-with=20
"_.DateTime(new_nsbirthday)"&gt;<BR>&nbsp; &lt;dtml-var "'%s/%s/%s' % =
(year(),=20
mm(), dd())"&gt;<BR>&lt;/dtml-with&gt;</STRONG></FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>with this code :</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial><FONT size=3D2><STRONG>&lt;dtml-call=20
"insertNoteService(nsentrydate =3D "_.DateTime(new_nsentrydate)" =
'%s/%s/%s' %=20
(year(), mm(), dd()), nsname =3D new_nsname,=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nsadresse =3D new_nsadresse, nslocation =3D new_nslocation,=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nscountry =3D new_nscountry, nsbirthday =3D "_.DateTime(new_nsbirthday)" =
'%s/%s/%s'=20
% (year(), mm(),=20
dd()),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nsbirthplace =3D new_nsbirthplace, nstext =3D=20
new_nstext,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nsstatus =3D 0, nstype =3D new_nstype, nssociety =3D new_nssociety,=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nsservice =3D new_nsservice)"&gt;<BR></STRONG></FONT><BR>i get the =
folowing=20
error:</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial><EM>Invalid attribute name, =
"_.DateTime(new_nsentrydate)",=20
for tag &lt;dtml-call "insertNoteService(nsentrydate =3D=20
"_.DateTime(new_nsentrydate)" '%s/%s/%s' % (year(), mm(), dd()), nsname =
=3D=20
new_nsname, nsadresse =3D new_nsadresse, nslocation =3D new_nslocation, =
nscountry =3D=20
new_nscountry, nsbirthday =3D "_.DateTime(new_nsbirthday)" '%s/%s/%s' % =
(year(),=20
mm(), dd()), nsbirthplace =3D new_nsbirthplace, nstext =3D new_nstext, =
nsstatus =3D 0,=20
nstype =3D new_nstype, nssociety =3D new_nssociety, nsservice =3D =
new_nsservice)"&gt;,=20
on line 4 of addNoteService_html</EM></FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>
<DIV><FONT face=3DArial>with this code :</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>&lt;dtml-call=20
"insertNoteService(nsentrydate =3D "_.DateTime(new_nsentrydate)" =
'%s/%s/%s' %=20
(year(), mm(), dd())", nsname =3D new_nsname,=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nsadresse =3D new_nsadresse, nslocation =3D new_nslocation,=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nscountry =3D new_nscountry, nsbirthday =3D "_.DateTime(new_nsbirthday)" =
'%s/%s/%s'=20
% (year(), mm(),=20
dd())",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nsbirthplace =3D new_nsbirthplace, nstext =3D=20
new_nstext,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nsstatus =3D 0, nstype =3D new_nstype, nssociety =3D new_nssociety,=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
nsservice =3D new_nsservice)"&gt;</STRONG></FONT></DIV><FONT=20
face=3DArial></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT face=3DArial></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial><FONT face=3DArial>i don't get&nbsp; Errors, but =
it doesn't=20
work.</DIV>
<DIV><BR></DIV></FONT>
<DIV>Here is my sql code:</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>INSERT INTO noteservice =
(ns_entrydate,=20
ns_name,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ns_adresse, =
ns_location,=20
ns_country, ns_birthday,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
ns_birthplace,=20
ns_text, ns_status, ns_type,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
ns_society,=20
ns_service)<BR>VALUES('&lt;dtml-var nsentrydate&gt;', '&lt;dtml-var =
nsname=20
fmt=3Dsql-quote&gt;', '&lt;dtml-var nsadresse fmt=3Dsql-quote&gt;', =
'&lt;dtml-var=20
nslocation fmt=3Dsql-quote&gt;', '&lt;dtml-var nscountry =
fmt=3Dsql-quote&gt;',=20
'&lt;dtml-var nsbirthday&gt;','&lt;dtml-var nsbirthplace =
fmt=3Dsql-quote&gt;',=20
'&lt;dtml-var nstext fmt=3Dsql-quote&gt;', &lt;dtml-var nsstatus&gt;, =
&lt;dtml-var=20
nstype&gt;, &lt;dtml-var nssociety&gt;, &lt;dtml-var =
nsservice&gt;)&nbsp;&nbsp;=20
</STRONG></FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>when i use this code :</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>&lt;dtml-with=20
"_.DateTime('01.01.1900')"&gt;<BR>&lt;dtml-var&nbsp; "'%s/%s/%s' % =
(year(),=20
mm(), dd())"&gt;<BR>&lt;/dtml-with&gt;</STRONG></FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>i get 1900/01/01</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV><FONT face=3DArial>
<DIV><FONT face=3DArial>when i use this code :</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2><STRONG>&lt;dtml-let=20
tert=3D"'01.01.1900'"&gt;<BR>&nbsp;&lt;dtml-var "_.DateTime(tert)"=20
fmt=3D"%Y/%m/%d"&gt;<BR>&lt;/dtml-let&gt;</STRONG></FONT></FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>i get=20
2036/02/07&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<STRONG>Why?<BR></STRONG></FONT></DIV>
<DIV><FONT face=3DArial>
<DIV><FONT face=3DArial>when i use this code :</FONT></DIV>
<DIV>&nbsp;</DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>&lt;dtml-var =
"_.DateTime('01.01.1900')"=20
fmt=3D"%Y/%m/%d"&gt;</STRONG></FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>i get=20
2036/02/07&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<STRONG>Why?<BR></STRONG></DIV></FONT><FONT face=3DArial>
<DIV><FONT face=3DArial>when i use this code :</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2><STRONG>&lt;dtml-var "ZopeTime('01.01.1900')"=20
fmt=3D"%Y/%m/%d"&gt;<BR></STRONG></FONT></DIV>
<DIV>i get 2036/02/07&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<STRONG>Why?<BR></STRONG></DIV>
<DIV>Could you explain me how i must handle date fields in zope?</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>Finally, i want formatting a date as 2000/01/01 and then put in my =
table=20
with a sql method.</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV>Any suggestions or a good example will be=20
apprecieated...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=20
</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><STRONG><EM>$Regards</EM></STRONG></DIV>
<DIV><STRONG><EM></EM></STRONG>&nbsp;</DIV>
<DIV><STRONG><EM>MM</EM></STRONG></DIV></FONT></BODY></HTML>

------=_NextPart_000_001E_01BFF7AD.BF0A2820--