New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TIME and TIMESTAMP to EXTRACT to obtain time in the zone of a WITH TIME ZONE value as a WITHOUT TIME ZONE value [CORE6492] #6722
Comments
Commented by: @asfernandes While the internal representation of with-tz types stores the utc value, people generally see that values formated to the session time zone. It would be extremally non obvious to have that extracted values different than what they see that parts formatted. |
Commented by: @mrotteveel Rewritten to use (date)time in zone as the value to be extracted. |
Modified by: @mrotteveeldescription: As a follow-up to the discussion on firebird-devel titled "Current timestamp without timezone in given timezone", I suggest that we add TIME and TIMESTAMP to EXTRACT to be able to extract the UTC value of a WITH TIME ZONE type as an WITHOUT TIME ZONE type. This would have the following semantics: <part> from <datetime> => <resulttype> This solution would be non-standard, but would provide a nice symmetry with EXTRACT(TIMEZONE_HOUR FROM ...) and EXTRACT(TIMEZONE_MINUTE FROM ...) => As a follow-up to the discussion on firebird-devel titled "Current timestamp without timezone in given timezone", I suggest that we add TIME and TIMESTAMP to EXTRACT to be able to extract the time in the zone of a WITH TIME ZONE type as a WITHOUT TIME ZONE type. This would have the following semantics: <part> from <datetime> => <resulttype> Primary rationale for this feature is that CAST(tz_value as TIME[STAMP] WITHOUT TIME ZONE) converts to the time in the session time zone before conversion to WITHOUT TIME ZONE. Currently, getting the time in the zone as a WITHOUT TIME ZONE requires conversion to string, use of substring and then casting to TIME/TIMESTAMP. summary: Add TIME and TIMESTAMP to EXTRACT to be able to obtain UTC value of WITH TIME ZONE types. => Add TIME and TIMESTAMP to EXTRACT to obtain time in the zone of a WITH TIME ZONE value as a WITHOUT TIME ZONE value |
Commented by: @aafemt In fourth example didn't you mean time_with_tz...? |
Modified by: @mrotteveeldescription: As a follow-up to the discussion on firebird-devel titled "Current timestamp without timezone in given timezone", I suggest that we add TIME and TIMESTAMP to EXTRACT to be able to extract the time in the zone of a WITH TIME ZONE type as a WITHOUT TIME ZONE type. This would have the following semantics: <part> from <datetime> => <resulttype> Primary rationale for this feature is that CAST(tz_value as TIME[STAMP] WITHOUT TIME ZONE) converts to the time in the session time zone before conversion to WITHOUT TIME ZONE. Currently, getting the time in the zone as a WITHOUT TIME ZONE requires conversion to string, use of substring and then casting to TIME/TIMESTAMP. => As a follow-up to the discussion on firebird-devel titled "Current timestamp without timezone in given timezone", I suggest that we add TIME and TIMESTAMP to EXTRACT to be able to extract the time in the zone of a WITH TIME ZONE type as a WITHOUT TIME ZONE type. This would have the following semantics: <part> from <datetime> => <resulttype> Primary rationale for this feature is that CAST(tz_value as TIME[STAMP] WITHOUT TIME ZONE) converts to the time in the session time zone before conversion to WITHOUT TIME ZONE. Currently, getting the time in the zone as a WITHOUT TIME ZONE requires conversion to string, use of substring and then casting to TIME/TIMESTAMP. |
Commented by: @mrotteveel @dimitry You're right, fixed it. Extracting a timestamp from time might not make much sense in a strict interpretation of the word EXTRACT, but defining it like this will make a complete definition that allows equivalent "from <type1> to <type2>" conversions as allowed by cast. |
Commented by: @aafemt So we can end up with non-standard EXTRACT with standard behavior and standard CAST with non-standard behavior. |
Commented by: @mrotteveel @dimitry that would have the knock-on effect of SET BIND no longer translating values to the session time zone, making that feature useless. |
Commented by: @aafemt Ah, right, I forgot about it, sorry. |
Commented by: @asfernandes I'm very against these: TIMESTAMP from time_with_tz => time in zone @ current_date as TIMESTAMP WITHOUT TIME ZONE This has nothing to do with EXTRACT. Also, if this is implemented, DATE from TIMESTAMP(s)/DATE should also be implemented. |
Commented by: @mrotteveel @adriano My suggestion for those three options is to have an equivalent for the behaviour that cast has as well. The only alternatives I can think of is |
Submitted by: @mrotteveel
As a follow-up to the discussion on firebird-devel titled "Current timestamp without timezone in given timezone", I suggest that we add TIME and TIMESTAMP to EXTRACT to be able to extract the time in the zone of a WITH TIME ZONE type as a WITHOUT TIME ZONE type.
This would have the following semantics:
<part> from <datetime> => <resulttype>
TIME from timestamp_with_tz => time in zone (@ specified date) as TIME WITHOUT TIME ZONE
TIMESTAMP from timestamp_with_tz => time+date in zone as TIMESTAMP WITHOUT TIME ZONE
TIME from time_with_tz => time in zone as TIME WITHOUT TIME ZONE
TIMESTAMP from time_with_tz => time in zone @ current_date as TIMESTAMP WITHOUT TIME ZONE
TIME from timestamp_without_tz => cast to TIME WITHOUT TIME ZONE (strip date)
TIMESTAMP from timestamp_without_tz => original value (timestamp_without_tz )
TIME from time_without_tz => original value (time_without_tz)
TIMESTAMP from time_without_tz => cast to TIMESTAMP WITHOUT TIME ZONE (value @ current_date)
TIME from date_val => conversion error
TIMESTAMP from date_val => cast to TIMESTAMP WITHOUT TIME ZONE (current_date + 00:00:00 as time)
Primary rationale for this feature is that CAST(tz_value as TIME[STAMP] WITHOUT TIME ZONE) converts to the time in the session time zone before conversion to WITHOUT TIME ZONE. Currently, getting the time in the zone as a WITHOUT TIME ZONE requires conversion to string, use of substring and then casting to TIME/TIMESTAMP.
The text was updated successfully, but these errors were encountered: