Question: How would I clear a date field?

The following code doesn't seem to work:

```
    if (Xrm.Page.getAttribute("new_boolfield1").getValue() != null) {

       switch(Xrm.Page.getAttribute("new_boolfield1").getValue()) {

        case false:

          Xrm.Page.getAttribute("new_datefield1").setValue(null); // this doesn't work
          Xrm.Page.getAttribute("new_datefield1").setValue(); // this doesn't work either

        case true:

          Xrm.Page.getAttribute("new_datefield1").setValue(new Date()); 
        }
     }

```

Answer: 
```
Xrm.Page.getAttribute('new_datefield1').setValue();

```

Should work. Make sure that you're not setting your date field anywhere else and make sure to put `break` statements in

<http://crmbusiness.wordpress.com/2012/05/17/crm-2011-javascript-to-set-the-current-date-and-time/>

\*\* EDIT \*\* It's your case statement

```
var b = false;
switch(b) {
  case false:
    console.log("false");
  case true:
    console.log("true");
}

```

Without a break statement this will print "false true"

```
var b = false;
switch(b) {
  case false:
    console.log("false");
    break;
  case true:
    console.log("true");
    break; // <- not really required but good practise
}

```
The right way to clear a field in CRM 2011 is to set its value to `null`

```js
Xrm.Page.getAttribute("new_datefield1").setValue(null);

```

If your field still not cleared, can be for two reasons:

1. you are setting the date somewhere else (as jasonscript
suggested)
2. your `new_boolfield1` is not a boolean field (`two
options` inside CRM) but one optionset

You can easily test these conditions, the first check outside the switch, the second with an `alert` or a `console.log`