EnjoY | Database Research And Development: PostgreSQL: Understand TIMESTAMP vs TIMESTAMP WITH TIME ZONE

Friday, January 29, 2021

PostgreSQL: Understand TIMESTAMP vs TIMESTAMP WITH TIME ZONE

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

In this post, I am sharing a practical difference between TIMESTAMP and TIMESTAMP WITH TIME ZONE data type of PostgreSQL.

To understand the difference is a very important. Otherwise, it will affect your business or dataset.

I found many people are using TIMESTAMP WITH TIME ZONE data time, without knowing that this data type will change the time value according to different TIME ZONEs.

TIMESTAMP: Never change time basis on time zones
TIMESTAMP WITH TIME ZONE: Change the time basis on time zones

Please check the below demonstration:

Create two sample tables:

Insert CURRENT_TIMESTAMP:

Check the current timezone of your system:

Check the table data, which entered as your system time zone:

Now, change the timezone in your session:

Now, check the table data:
You can see, for ABC table no change and XYZ table changed as per the new time zone.


No comments:

Post a Comment

It’s all about friendly conversation here at small review :) I’d love to be hear your thoughts!

Be sure to check back again because I do make every effort to reply to your comments here.

Featured Post

SQL Server : SELECT all columns to be good or bad in database system

This article is half-done without your Comment! *** Please share your thoughts via Comment *** In this post, I am going to write about one o...

Popular Posts