# Is it possible to set an input's "value" as a variable from another cell?

**URL:** <https://talk.observablehq.com/t/is-it-possible-to-set-an-inputs-value-as-a-variable-from-another-cell/1297>\
**Category:** Uncategorized\
**Created:** [October 9, 2018, 2:44pm UTC](https://talk.observablehq.com/t/is-it-possible-to-set-an-inputs-value-as-a-variable-from-another-cell/1297 "2018-10-09T14:44:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![palewire](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/palewire/32/25_2.png) [@palewire](https://talk.observablehq.com/u/palewire)\
**Post date:** [October 9, 2018, 2:44pm UTC](https://talk.observablehq.com/t/is-it-possible-to-set-an-inputs-value-as-a-variable-from-another-cell/1297/1 "2018-10-09T14:44:14Z")

</div>

It’s very possible I am screwing up something simple here, but is something like workable?

viewof minChartDate = date({  
title: “Minimum date”,  
min: d3.min(myArray, d =\> d.date),  
max: new Date(),  
value: d3.min(myArray, d =\> d.date)  
})

If so, it might be helpful to include an example in the inputs documentation, for fools like me.

---

<div class="post-metadata">

**Author:** ![jrunning](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jrunning/32/1107_2.png) [@jrunning](https://talk.observablehq.com/u/jrunning)\
**Post date:** [October 9, 2018, 5:03pm UTC](https://talk.observablehq.com/t/is-it-possible-to-set-an-inputs-value-as-a-variable-from-another-cell/1297/2 "2018-10-09T17:03:12Z")

</div>

Could you link to your notebook? Setting `value` from another cell is working fine for me:

> **[viewof date](https://beta.observablehq.com/@jrunning/viewof-date)**
>
> An Observable notebook by Jordan Running.

---

<div class="post-metadata">

**Author:** ![palewire](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/palewire/32/25_2.png) [@palewire](https://talk.observablehq.com/u/palewire)\
**Post date:** [October 9, 2018, 5:27pm UTC](https://talk.observablehq.com/t/is-it-possible-to-set-an-inputs-value-as-a-variable-from-another-cell/1297/3 "2018-10-09T17:27:48Z")

</div>

Ah. Thanks for the example. The difference is that you are using date strings and I am using date objects. Your strings appear to be working, and my objects appear to be not.

> **[Trump's Twitter Terminology](https://beta.observablehq.com/@palewire/trumps-twitter-terminology)**
>
> An Observable notebook by Ben Welsh.

---

<div class="post-metadata">

**Author:** ![jrunning](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jrunning/32/1107_2.png) [@jrunning](https://talk.observablehq.com/u/jrunning)\
**Post date:** [October 9, 2018, 5:36pm UTC](https://talk.observablehq.com/t/is-it-possible-to-set-an-inputs-value-as-a-variable-from-another-cell/1297/4 "2018-10-09T17:36:18Z")

</div>

Ah, yeah, that would do it. I tried Date objects first as well. FWIW you can easily convert a Date object into that format with `dateObj.toISOString().slice(0, 9)`.

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [October 9, 2018, 6:14pm UTC](https://talk.observablehq.com/t/is-it-possible-to-set-an-inputs-value-as-a-variable-from-another-cell/1297/5 "2018-10-09T18:14:47Z")

</div>

I’d be careful about using _date_.toISOString, since that will format the dates in UTC time rather than local time; that might give you the wrong date.

Here’s a function that will format a date as required by HTML:

> **[A Note on Date Inputs](https://beta.observablehq.com/@mbostock/a-note-on-date-inputs)**
>
> An Observable notebook by Mike Bostock.

You can also use d3-time-format:

```auto
format = d3.timeFormat("%Y-%m-%d")

```

---

<div class="post-metadata">

**Author:** ![palewire](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/palewire/32/25_2.png) [@palewire](https://talk.observablehq.com/u/palewire)\
**Post date:** [October 10, 2018, 12:00am UTC](https://talk.observablehq.com/t/is-it-possible-to-set-an-inputs-value-as-a-variable-from-another-cell/1297/6 "2018-10-10T00:00:59Z")

</div>

Thanks for the remedial education. I needed it here.
