# Google Sheet - Multiple Cells

**URL:** <https://discourse.nodered.org/t/google-sheet-multiple-cells/50075>\
**Category:** General\
**Created:** [23 August 2021 17:05 UTC](https://discourse.nodered.org/t/google-sheet-multiple-cells/50075 "2021-08-23T17:05:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DoubleDutch](https://avatars.discourse-cdn.com/v4/letter/d/b487fb/32.png) [@DoubleDutch](https://discourse.nodered.org/u/DoubleDutch)\
**Post date:** [23 August 2021 17:05 UTC](https://discourse.nodered.org/t/google-sheet-multiple-cells/50075/1 "2021-08-23T17:05:36Z")

</div>

Apologies for this very basic question but - Using Home Assistant, I’m trying to store temperature data in a google sheet. It works but the flow below only puts the temperature in the sheet and I would like the current date/time as well so I end up in my spreadsheet with two columns.

|23 Aug 2021 16:15|28.2|

What do I need to change to my flow to get this date/time column passed to the google sheet component?

 ![PortugalTempNode](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/529074b0338c5102ca0da83cc0f8a27a17ed81fe.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 August 2021 22:21 UTC](https://discourse.nodered.org/t/google-sheet-multiple-cells/50075/2 "2021-08-23T22:21:13Z")

</div>

Look at the built in help, the states

> The data to be written to the sheet at the specified cells, a string will write to a single cell an array will write a row and a matrix will write multiple rows

So instead of sending separate messages, send an array with `[timestamp,value]`...

- delete the timestamp node
- add a function node BETWEEN the temperature node and the GSheet node containing...

```auto
msg.payload = [Date.now(), msg.payload];
return msg;

```

* * *

PS: untested (I have never used or installed GSheet)

---

<div class="post-metadata">

**Author:** ![rgerrans](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@rgerrans](https://discourse.nodered.org/u/rgerrans)\
**Post date:** [24 August 2021 16:40 UTC](https://discourse.nodered.org/t/google-sheet-multiple-cells/50075/3 "2021-08-24T16:40:00Z")

</div>

I don't remember the exact issue with using the Date.now() but I ended up with the following function to get it into Excel's date format

```auto
var date1 = new Date();
var dateexcel = 25569.0 + ((date1.getTime() - (date1.getTimezoneOffset() * 60 * 1000)) / (1000 * 60 * 60 * 24));
msg.dateexcel = dateexcel.toString().substr(0,20);
return msg;

```

That then feeds into a template node to format (probably could have integrated that into my function node and saved a step)

`["{{dateexcel}}","{{payload}}"]`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 September 2021 16:40 UTC](https://discourse.nodered.org/t/google-sheet-multiple-cells/50075/4 "2021-09-07T16:40:33Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
