Skip to content

Commit 27a1286

Browse files
Adding PostgreSQL examples
1 parent 7d14d68 commit 27a1286

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

content/integrate/redis-data-integration/data-pipelines/transform-examples/formatting-date-and-time-values.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,70 @@ SQL Server supports the following date and time data types:
120120

121121

122122
<!-- TODO [ilianiliev-redis]: Test and document the dynamic expressions for the rest of the supported databases - MySQL, PostgresSQL, MongoDB -->
123+
124+
125+
126+
----
127+
128+
## PostgreSQL
129+
130+
PostgreSQL supports the following date and time data types:
131+
132+
- `date` - represented by Debezium as number of days since epoch (1970-01-01). You can multiply the value by 86400 (the number of seconds in a day) to convert it to seconds since epoch and then use the `STRFTIME` or `DATE` functions to format it.
133+
```yaml
134+
transform:
135+
- uses: add_field
136+
with:
137+
fields:
138+
- field: with_default_date_format
139+
language: sql
140+
# Uses the default DATE format
141+
expression: DATE(event_date * 86400, 'unixepoch')
142+
```
143+
144+
- `time` - the time of microseconds since midnight.
145+
```yaml
146+
transform:
147+
- uses: add_field
148+
with:
149+
fields:
150+
- field: formatted_time
151+
language: sql
152+
# Divide by 1000000 to convert microseconds to seconds
153+
expression: TIME(event_time / 1000000, 'unixepoch', 'utc')
154+
```
155+
156+
- `time with time zone` - a string representation of the time with timezone information, where the timezone is GMT, example `07:15:00Z`.
157+
```yaml
158+
transform:
159+
- uses: add_field
160+
with:
161+
fields:
162+
- field: formatted_time_with_tz
163+
language: sql
164+
expression: STRFTIME('%H:%M:%S', event_time_with_time_zone)
165+
```
166+
167+
- `timestamp` - represented by Debezium as a 64-bit integer representing the microseconds since epoch. You can use the `STRFTIME` function to format it.
168+
```yaml
169+
transform:
170+
- uses: add_field
171+
with:
172+
fields:
173+
- field: formatted_timestamp
174+
language: sql
175+
# Divide by 1000000 to convert microseconds to seconds
176+
expression: STRFTIME('%Y-%m-%d %H:%M:%S', event_timestamp / 1000000, 'unixepoch')
177+
```
178+
179+
- `timestamp with time zone` - represented by Debezium as a string representation of the timestamp with time zone information, where the timezone is GMT, e.g. `2025-06-07T10:15:00.000000Z`
180+
```yaml
181+
transform:
182+
- uses: add_field
183+
with:
184+
fields:
185+
- field: formatted_timestamp_with_tz
186+
language: sql
187+
# Divide by 1000000 to convert microseconds to seconds
188+
expression: STRFTIME('%Y-%m-%d %H:%M:%S', event_timestamp_with_time_zone)
189+
```

content/integrate/redis-data-integration/data-pipelines/transform-examples/map-example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,4 @@ like the following:
167167
6) "3:35.0"
168168
7) "storagesize"
169169
8) "6.71MB"
170-
```
170+
```

0 commit comments

Comments
 (0)