[Zope] setting date to Null in MS SQL?

McDonnell, Larry lmcdonnell@protonenergy.com
Thu, 22 May 2003 12:23:39 -0400


Hi,

Sorry, this MS Access.

-----Original Message-----
From: Kelley, Sean [mailto:SKelley@ci.santa-rosa.ca.us]
Sent: Thursday, May 22, 2003 12:07 PM
To: McDonnell, Larry; 'zope@zope.org'
Subject: RE: [Zope] setting date to Null in MS SQL?


Hi, thanks

Are you using Microsoft SQL server?  This does not submit for me without
commas after the NULL and variable lines and even then it still does not
insert the NULL into the database- instead 1/1/1900  Like I said, it inserts
NULL for and update but not for insert

I wonder if it is a microsoft thing.

--Sean


<dtml-if AppDelDate>
     <dtml-if "AppDelDate==''">
       NULL,
     <dtml-else>
       <dtml-sqlvar AppDelDate type=string>,
     </dtml-if>
   <dtml-else>
     NULL,
   </dtml-if>

-----Original Message-----
From: McDonnell, Larry [mailto:lmcdonnell@protonenergy.com]
Sent: Thursday, May 22, 2003 6:22 AM
To: Kelley, Sean; 'zope@zope.org'
Subject: RE: [Zope] setting date to Null in MS SQL?


Hi,

I do this within the zsql method - 

<dtml-if creation_date>
  <dtml-if "creation_date==''">
    NULL
  <dtml-else>
    <dtml-sqlvar creation_date type=string>
  </dtml-if>
<dtml-else>
  NULL
</dtml-if>

Chris Kratz provided me with this awhile ago. Hope this helps.

-----Original Message-----
From: Kelley, Sean [mailto:SKelley@ci.santa-rosa.ca.us]
Sent: Wednesday, May 21, 2003 6:38 PM
To: 'zope@zope.org'
Subject: [Zope] setting date to Null in MS SQL?


I have a simple app where I need to let people set dates to null via a form.
I am trying to test for an empty form field and set the value to NULL if
empty.  It seems to work on form submission but when I do a database query I
see it is actually set to 1/1/1900
I have found a way to update a record if it already has a value and you
clear the form field, but for some reason this same method does not work for
an initial insert.

In both of my sql methods I have:

<dtml-if "AppDelDate==''">
       AppDelDate=NULL,
 <dtml-else>
       '<dtml-var name="AppDelDate" sql_quote>',
 </dtml-if>

What am I missing?

_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )