Ask Your Question
1

How can I translate IANA time zone into an integer value in a SQL query?

asked 2022-08-04 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-06-06 10:00:00 +0000

david gravatar image

It is not possible to directly translate IANA time zone into an integer value in a SQL query as IANA time zones are represented by strings that do not correspond to a numeric system. However, you can use a lookup table that maps each IANA time zone to a unique integer value that can be used in your SQL query. Here is an example of a lookup table:

| IANA Time Zone | Integer Value | | :------------ | :------------ | | America/NewYork | 1 | | America/Chicago | 2 | | America/LosAngeles | 3 | | Europe/London | 4 | | Europe/Paris | 5 |

You can then join your main table with this lookup table on the IANA time zone column to get the corresponding integer value. For example:

SELECT t.*, l.integer_value
FROM my_table t
JOIN lookup_table l ON t.iana_time_zone = l.iana_time_zone

This will return all columns from the main table as well as the corresponding integer value from the lookup table for each IANA time zone.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-08-04 11:00:00 +0000

Seen: 9 times

Last updated: Jun 06 '21