mirror of
https://github.com/n8n-io/n8n-docs.git
synced 2026-03-27 09:28:43 +07:00
Doc 1497/mention our pg library that we use for postgres node and the (#3346)
This commit is contained in:
committed by
GitHub
parent
d23703ad1f
commit
e6974d4665
@@ -43,3 +43,17 @@ To avoid complications with how n8n and Postgres interpret timestamp and time zo
|
||||
- **Use UTC when storing and passing dates**: Using UTC helps avoid confusion over timezone conversions when converting dates between different representations and systems.
|
||||
- **Set the execution timezone**: Set the global timezone in n8n using either [environment variables](/hosting/configuration/configuration-examples/time-zone.md) (for self-hosted) or in the [settings](/manage-cloud/set-cloud-timezone.md) (for n8n Cloud). You can set a workflow-specific timezone in the [workflow settings](/workflows/settings.md).
|
||||
- **Use ISO 8601 format**: The [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601) encodes the day of the month, month, year, hour, minutes, and seconds in a standardized string. n8n passes dates between nodes as strings and uses [Luxon](/code/cookbook/luxon.md) to parse dates. If you need to cast to ISO 8601 explicitly, you can use the [Date & Time node](/integrations/builtin/core-nodes/n8n-nodes-base.datetime.md) and a custom format set to the string `yyyy-MM-dd'T'HH:mm:ss`.
|
||||
|
||||
## Outputting Date columns as date strings instead of ISO datetime strings
|
||||
|
||||
n8n's uses the [`pg` package](https://www.npmjs.com/package/pg) to integrate with Postgres, which affects how n8n processes date, timestamp, and related types from Postgres.
|
||||
|
||||
The `pg` package parses `DATE` values into `new Date(row_value)` by default, which produces a date that follows the [ISO 8601 datetime string](https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations) format. For example, a date of `2025-12-25` might produce a datetime sting of `2025-12-25T23:00:00.000Z` depending on the instance's timezone settings.
|
||||
|
||||
To work around this, use the [Postgres `TO_CHAR` function](https://www.postgresql.org/docs/current/functions-formatting.html#FUNCTIONS-FORMATTING) to format the date into the expected format at query time:
|
||||
|
||||
```sql
|
||||
SELECT TO_CHAR(date_col, 'YYYY-MM-DD') AS date_col_as_date FROM table_with_date_col
|
||||
```
|
||||
|
||||
This will produce the date as a string without the time or timezone components. To continue the earlier example, with this casting, a date of `2025-12-25` would produce the string `2025-12-25`. You can find out more in the [`pg` package documentation on dates](https://node-postgres.com/features/types#date--timestamp--timestamptz).
|
||||
|
||||
@@ -61,6 +61,7 @@ Cron
|
||||
[Cc]rypto
|
||||
Datadog
|
||||
Datastore
|
||||
[Dd]atetimes?
|
||||
[Dd]edupe
|
||||
[Dd]eduplication
|
||||
DeepL
|
||||
|
||||
Reference in New Issue
Block a user