timestamptz - store the same value without converting to system TZ
Hi,
I am trying to store a value into a Timestamptz datatype.
While retrieving the value, I see that it gets converted to the TZ of DB. Same is not true with timetz datatype.
Is there a way to retain the exact same value as is in input while using timestamptz ?
I understand that in essence the value is same, but I want to retain the value in same TZ as was in input.
I am trying to store a value into a Timestamptz datatype.
While retrieving the value, I see that it gets converted to the TZ of DB. Same is not true with timetz datatype.
Is there a way to retain the exact same value as is in input while using timestamptz ?
I understand that in essence the value is same, but I want to retain the value in same TZ as was in input.
=> select ('2014-05-10 07:00:37.327348-07:00' :: timestamptz(6)) ;
Output:: 2014-05-10 09:00:37.327348-05
0
Comments
Try using AT TIMEZONE
AT TIMEZONE
Hope this helps
NC
Not sure, if this is the requirement. Hope this helps
NC
The intent is to capture exact same string as was in input and store it in TimestampTZ column.
Having said that,
In the first method, as I mentioned earlier, it implicitly converts the TZ to local DB TZ.
In second, it trims the timezone/meridian.
and in third, we are converting it to a TZ of choice. And in any case, concatenating any coerced values will implicitly typecast it to Varchar and thus, rendering it unfit to be stored in a column of type TSTZ without explicitly typecasting it back to TSTZ.
So unfortunately, these methods don't seem to be fitting in.
I am trying something with intervals, but that also is not helping.
Also, TTZ does not have any such issue: