Hi @god_prophet ,
In postgreSQL data type of datetime and datetimetz serves same purpose. It will store as TIMESTAMPTZ datatype in Database.
Whereas when you define datatype as datetimenotz, in database it will store as TIMESTAMP datatype.
(However, when you see the data from schema's data tab in adobe campaign UI, It will displays the same for both datatypes)
Consider, when you create 3 attributes as below in adobe campaign,
<attribute label="Datetime" name="datetimeField" type="datetime"/>
<attribute label="Datetimetz" name="datetimetzField" type="datetimetz"/>
<attribute label="Datetimenotz" name="datetimenotzField" type="datetimenotz"/>
And when you update the database structure, you can notice the data type generated in database,
ADD COLUMN tsDatetimeField TIMESTAMPTZ,
ADD COLUMN tsDatetimetzField TIMESTAMPTZ,
ADD COLUMN tsDatetimenotzField TIMESTAMP;
And difference between TIMESTAMP and TIMESTAMPTZ is,
- timestamp: a timestamp without timezone one.
- timestamptz: timestamp with a timezone.
The timestamp datatype allows you to store both date and time. However, it does not have any time zone data. It means that when you change the timezone of your database server, the timestamp value stored in the database will not change automatically.
The timestamptz datatype is the timestamp with the time zone. The timestamptz datatype is a time zone-aware date and time data type.
PostgreSQL stores the timestamptz in UTC value.
- When you insert a value into a timestamptz column, PostgreSQL converts the timestamptz value into a UTC value and stores the UTC value in the table.
- When you query timestamptz from the database, PostgreSQL converts the UTC value back to the time value of the timezone set by the database server, the user, or the current database connection.
Reference: Understanding PostgreSQL Timestamp Data Types
So considering your use case, you can decide which datatype need to be used!
~ Parthasarathy S