December 6, 2004 at 9:14 am
Is there any way to SET a column to a null value programatically?
I need to remove the date value from a date column after it has been set to some value.
December 6, 2004 at 10:52 am
I would probably use the value that microsoft uses with a NULL date value (1900-01-01 00:00:00.000)
Good Hunting!
AJ Ahrens
webmaster@kritter.net
December 6, 2004 at 11:32 am
I'm not sure I'm following you here.
from VB
SomeField.value = null
from SQL
Update MyTable Set MyField = null where MyField = @MyDate
or
Update MyTable Set MyField = nullif(@MyDate, MyField)
December 6, 2004 at 12:46 pm
Thanks AJ
That is what I do now but I then have to edit the redisplay of the field as the users are confused when they see the 1900-01-01 date.
Just wanted to know if there was some simple way.
Somewhere I saw that Ctrl-0 will put a null in a date field, but I don't know how to get the user to input that in a field.
Jack
December 6, 2004 at 1:00 pm
Ctrl-0 works only in enterprise manager to set a value to null.
Are you using access or vb to display the information?
in access you can simply set the value to null and leave it like that.
In vb I guess you have to set it to "" (if you don't want to show a meaningless date) and then convert it back to a date once the user entered the data (to resend it on the server).
December 6, 2004 at 1:18 pm
I am using Cold Fusion and MS-SQL, and will just have to edit the field before display.
function blankdate(a){
var xdate = null
a.value=xdate
}
<input name=StartDate size=12
onclick = "blankdate(this)" ondblclick = "newdate(this)"
value = '#dateformat(tempdate,"dd-mmm-yyyy")#'
ondblclick="newdate(this)">
December 12, 2004 at 7:59 am
Try this:
UPDATE MyTable SET DateField = CAST(NULL AS DATETIME) WHERE ID = 1
or
UPDATE MyTable SET DateField = NULL WHERE ID = 1
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply