I can not add current date and time to a google doc

Describe the problem/error/question

Hello, I am trying to write the current date and time (from a date and time node) into one of my google sheet rows. I try and drag it over as seen in the image, but it just turns red (this is a consistent issue I have). I can do a fixed string or I can bring it over from the time schedule. But the currentDate does not seem to work. I guess its two fold, why cant i do this, and why do things turn red?

The result always comes out undefined, and I dont really understand why.

thankyou

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: most recent
  • Database (default: SQLite): na
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
  • Operating system: windows 11

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

hi @n8ntesting2024

You getting the date from a previous node, not the one immediately before. Try this instead:

{{ $('Date & Time1').item.json.currentDate }}

Does that help?

Hi,

I dont really understand. I have pass both the Date and Time 1 and If into this node and it is still coming up red for created time from the If node. Why can I not just drag this over?

Thankyou

Can you please share the whole workflow? I feel I’m missing something on my end here, sorry!

Tips on how to share your workflow

Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

<your workflow>

Make sure that you’ve removed any sensitive information from your workflow and include dummy data or pinned data as much as you can!

To be honest, I actually think my issue could be something as simple as my node execution order, where the input date was ‘lower’ so the that exectued last.

I will tes this in more detai, but I think this could be what is causing the confussion.

But just to your earlier comment, when you referenced:

{{ $('Date & Time1').item.json.currentDate }}

Does this mean you can call a node (data) without passing it into the node?

Thankyou!

You can reference it if it was part of the chain. The UI should offer suggestions like this:

That allows you to reference Earlier Nodes that ran before the previous one.

If you drag and drop the pills from the left rather than typing expressions, you’re less likely to run into problems. Can you try that and let us know if that fixes things?

Ok so a good example of my issues. I have two variables.

One if SingleDate (which is a single date item).

The other is a node called itemstoCompare, which has 6 days items, this is shown below.

I then want to use an if node, to look at each of the 6 ‘Dates’ in itemstoCompare and to simply check if that date is after the SingleDate.

The output, should be these 6 items, either coming out as true or false.

but this does not seem to work, and I really cant see what I am doing wrong for what should be a simple operation.

I also tried this:

To be honest, I am a bit of a loss here, I dont undersand why I would need to write: {{ $node[“LastUpdate”].json[“LastUpdateDate”] }}. rather than {{ $json.LastUpdateDate }}

And I also dont know why I am not getting the correct data from the single item.

I think I undetstand that items wired directly do not need to have the node name called, but those in the chain, but wired before, need the node name - that makes sense.

The ‘if’ node in your screenshot will run 7 times independently, once for each item. If you want to compare the 6 items in the lower branch to the 1 item in the upper branch, you need a ‘merge’ node before the ‘if’ node. Set the ‘merge’ node to Combine → All possible combinations, assuming there will only ever be a single item in the upper branch. That should output 6 items, each with one date from the lower branch and the date from the upper branch included.

Would be great if you could share your workflow (or a simplified version) as gua suggested if you need any more help.

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