Inserting current date time with $now returns an error or null

Describe the problem/error/question

I am trying to insert the current datetime into a datatable in n8n (new feature)

What is the error message (if any)?

using this expression {{ $now.toISO() }} yields a null value and therefore inserts a null into my datetime field. Why?

Please share your workflow

{“nodes”: [{“parameters”: {},“type”: “n8n-nodes-base.manualTrigger”,“typeVersion”: 1,“position”: [0,0],“id”: “da6bb221-1a4d-421a-9d62-5da345e55cee”,“name”: “When clicking ‘Execute workflow’”},{“parameters”: {“dataTableId”: {“__rl”: true,“value”: “gh5uWNlBEtjwxVgc”,“mode”: “list”,“cachedResultName”: “test table”,“cachedResultUrl”: “/projects/RPfxwoiQX1tI6Zf9/datatables/gh5uWNlBEtjwxVgc”},“columns”: {“mappingMode”: “defineBelow”,“value”: {“name”: “test”,“my_date”: “={{ $now.toISO() }}”},“matchingColumns”: ,“schema”: [{“id”: “name”,“displayName”: “name”,“required”: false,“defaultMatch”: false,“display”: true,“type”: “string”,“readOnly”: false,“removed”: false},{“id”: “my_date”,“displayName”: “my_date”,“required”: false,“defaultMatch”: false,“display”: true,“type”: “dateTime”,“readOnly”: false,“removed”: false}],“attemptToConvertTypes”: false,“convertFieldsToString”: false},“options”: {}},“type”: “n8n-nodes-base.dataTable”,“typeVersion”: 1,“position”: [208,0],“id”: “7d12824b-c0c2-4fc3-88ee-136f17b85bfb”,“name”: “Insert row”}],“connections”: {“When clicking ‘Execute workflow’”: {“main”: [[{“node”: “Insert row”,“type”: “main”,“index”: 0}]]}},“pinData”: {},“meta”: {“instanceId”: “1e1207992a153f7bb2dd59fe30dd13dffd1a246602927a2c003ee7732ce4f22f”}}
Share the output returned by the last node

Information on your n8n setup

Debug info

core

  • n8nVersion: 1.118.2
  • platform: docker (self-hosted)
  • nodeJsVersion: 22.21.0
  • nodeEnv: production
  • database: sqlite
  • executionMode: regular
  • concurrency: -1
  • license: enterprise (production)
  • consumerId: 75be91dd-0f99-46b2-8b77-023ca838f5b8

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: memory

pruning

  • enabled: true
  • maxAge: 336 hours
  • maxCount: 10000 executions

client

  • userAgent: mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/605.1.15 (khtml, like gecko) version/18.6 safari/605.1.15
  • isTouchDevice: false

Generated at: 2025-11-10T21:42:28.712Z

Can you try this expression :

{{ $now.toUTC().toISO() }}

thanks but the result is identical – null is inserted into the database, rather than the current time. Maybe I have encountered a bug? Seems one of the simplest things to do. The datatype for my_date is DateTime.

I tried this expression

{{ new Date().toISOString() }}

which returns the current dateTime as as a String but then I get this error instead:

Problem in node ‘Insert row‘

Validation error with data table request: value ‘Tue Nov 11 2025 16:21:16 GMT+0000 (Coordinated Universal Time)’ does not match column type ‘date’: ‘my_date’ expects a dateTime but we got object

Consider using DateTime.fromFormat to work with custom date formats.

I figured it out. It appears that the default timezone was not set properly on the workflow and as a result it was setting the date to null.

{{ $now.toISO() }}

this works fine as long as I set the time zone in workflow settings

2 Likes

And the reason why this occurred was because the GENERIC_TIMEZONE environment variable was not set for my Docker environment.

I modified .env file and uncommented out the GENERIC_TIMEZONE variable and restarted n8n so the environment variable reloads. Now new workflows use my environment variable by default.

# Optional timezone to set which gets used by Cron-Node by default
# If not set New York time will be used
GENERIC_TIMEZONE=America/Toronto


Note that the docker-compose.yml default uses this GENERIC_TIMEZONE variable and if it is not set it appears not to default to any timezone (rather than New York as the comment states). At least it did in my instance. YMMV.

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