-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: Add support for convert_tz() and equivalent functions #27023
Comments
We have data that when queried is specific to a particular timezone. The data includes a UTC timestamp that represents the point in time that the data takes place. For example flight segments. We need to be able to query all segments that occurred on a specific day considering what the day is the timezone. The following example is from MariaDB.
This is an important issue to us because we would need to query all records, then in our code apply the timezone then exclude the records that don't apply. Obviously we could work around it, but we would prefer that the database handle it. |
@thebitmechanic why not convert the desired date to UTC instead in the comparison? e.g. |
(then to make this query fast you'd need to convert the test |
@knz start_timezone is an IANA timezone not an offset. Are you suggesting converting the following to a unix timestamp outside of the query? '2018-02-19'::interval + start_timezone I haven't seen anywhere in the cockroach docs that describes using IANA timezones. |
All the timezone names map to an offset expressed in seconds. Are you requesting a function that computes that amount of seconds as an INTERVAL value, so you can use it to compute what you need? |
Our database stores all timestamps as unix timestamps. The example above is looking for all air segments that occur on a day, 19 Feb 2018 for example. start_tstamp is essentially a departure date and time in seconds. We need to be able to apply the IANA timezone (start_timezone) to the start_tstamp to determine if the segment occurs on 19 Feb 2018. Without doing this the start_tstamp is a unix timestamp which of course is UTC. We could select a number of records, iterate over them while programmatically applying the IANA timezone looking for segments that occur on 19 Feb 2018, but it would be nice if the database could just handle it. |
We have marked this issue as stale because it has been inactive for |
crdb now supports the AT TIME ZONE operator |
FEATURE REQUEST
Dependent on but not identical to #26097 .
Add support for a convert_tz() function as described in https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_convert-tz , or equivalent.
Switchfour to comment below.
The text was updated successfully, but these errors were encountered: